1. C++ / Говнокод #23026

    0

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    #include "hex.h"
    #include "aes.h"
    #include <stdio.h>
    
    #define KEY (0x2b, 0x7e, 0x15, 0x16, 0x28, 0xae, 0xd2, 0xa6, 0xab, 0xf7, 0x15, 0x88, 0x09, 0xcf, 0x4f, 0x3c)
    #define DATA (0x32, 0x43, 0xf6, 0xa8, 0x88, 0x5a, 0x30, 0x8d, 0x31, 0x31, 0x98, 0xa2, 0xe0, 0x37, 0x07, 0x34)
    
    unsigned char enc[] = { BPP_AES_ENCRYPT_ARRAY(KEY, DATA) };
    
    int main() {
        for (int i=0; i<sizeof(enc); ++i) {
            printf("%02X ", enc[i]);
        }
        printf("\n");
        return 0;

    HAPKOMAH, 14 Мая 2017

    Комментарии (8)
  2. C++ / Говнокод #23013

    −17

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    26. 26
    27. 27
    28. 28
    29. 29
    30. 30
    31. 31
    32. 32
    33. 33
    34. 34
    35. 35
    36. 36
    37. 37
    38. 38
    39. 39
    40. 40
    41. 41
    42. 42
    43. 43
    44. 44
    45. 45
    46. 46
    47. 47
    48. 48
    49. 49
    50. 50
    51. 51
    52. 52
    53. 53
    54. 54
    #include <iostream>
    
    template <unsigned long destiny>
    struct dice {
        static const unsigned long roll = destiny * 1103515245 + 12345;
    };
    
    struct happiness {};
    
    template <typename XX, typename XY>
    struct love {
        typedef XX HACTEHbKA;
        typedef XY bormand;
    };
    
    template <int magic>
    struct bormand {
        static const unsigned long destiny = magic;
    };
    
    typedef
        love<bormand<196>, love<bormand<136>, love<bormand<230>,
        love<bormand< 80>, love<bormand< 83>, love<bormand<237>,
        love<bormand<100>, love<bormand< 51>, love<bormand< 19>,
        love<bormand<166>, love<bormand< 12>, love<bormand<153>,
        love<bormand<229>, love<bormand<141>, love<bormand<125>,
        happiness          >>>>>>>>>>>>>>>    HACTEHbKA;
    
    template<typename LOVE, unsigned long destiny>
    struct mystery {
        typedef
            love<bormand<LOVE::HACTEHbKA::destiny ^ dice<destiny>::roll>,
            typename mystery<typename LOVE::bormand,
            dice<destiny>::roll>::unveiled> unveiled;
    };
    
    template<unsigned long destiny>
    struct mystery<happiness, destiny> {
        typedef happiness unveiled;
    };
    
    template<typename love>
    std::string dreams_come_true(const love&) {
        return std::string(1, love::HACTEHbKA::destiny) +
               dreams_come_true(typename love::bormand());
    }
    
    std::string dreams_come_true(const happiness&) {
        return std::string();
    }
    
    int main() {
        std::cout << dreams_come_true(mystery<HACTEHbKA, 1>::unveiled());
    }

    Я перепесала http://govnokod.ru/21198 через вычесления на чистом уровне и кампеляции как моя чистая любовь

    guestinh0, 11 Мая 2017

    Комментарии (21)
  3. C++ / Говнокод #23012

    −2

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    26. 26
    27. 27
    28. 28
    29. 29
    30. 30
    31. 31
    32. 32
    33. 33
    34. 34
    35. 35
    36. 36
    37. 37
    38. 38
    void __attribute__ ((naked)) c8_handler_i() {
        asm volatile (
            "push %%ebp             \n\
            mov %%esp, %%ebp        \n\
            sub $20, %%esp          \n\
            mov %%eax, -4(%%ebp)    \n\
            mov %%ebx, -8(%%ebp)    \n\
            mov %%edx, -12(%%ebp)   \n\
            mov %[tasks], %%ebx     \n\
            mov %[cur_task], %%eax  \n\
            mov %[t_sz], %%edx      \n\
            mov (%%eax), %%eax      \n\
            mul %%edx               \n\
            add %%eax, %%ebx        \n\
            mov -4(%%ebp), %%eax    \n\
            mov %%eax, (%%ebx)      \n\
            mov -8(%%ebp), %%eax    \n\
            mov %%eax, 4(%%ebx)     \n\
            mov %%ecx, 8(%%ebx)     \n\
            mov -12(%%ebp), %%eax   \n\
            mov %%eax, 12(%%ebx)    \n\
            mov %%esi, 16(%%ebx)    \n\
            mov %%edi, 20(%%ebx)    \n\
            mov %%ebp, 24(%%ebx)    \n\
            addl $4, 24(%%ebx)      \n\
            mov (%%ebp), %%eax      \n\
            mov %%eax, 28(%%ebx)    \n\
            mov -4(%%ebp), %%eax    \n\
            mov -8(%%ebp), %%ebx    \n\
            mov -12(%%ebp), %%edx   \n\
            add $20, %%esp          \n\
            pop %%ebp               \n\
            iret"
            :: [tasks] "i" (tasks), [cur_task] "i" (&cur_task),
               [t_sz] "i" (sizeof(task)), [t_eip] "i" (offsetof(task, eip)), 
               [t_ebx] "i" (offsetof(reg_values, ebx))
        );
    }

    Когда решился написать ОС на C++

    cykablyad, 11 Мая 2017

    Комментарии (32)
  4. C++ / Говнокод #21126

    −79

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    26. 26
    27. 27
    28. 28
    29. 29
    30. 30
    31. 31
    32. 32
    33. 33
    34. 34
    35. 35
    36. 36
    37. 37
    38. 38
    39. 39
    40. 40
    41. 41
    42. 42
    43. 43
    44. 44
    45. 45
    46. 46
    47. 47
    48. 48
    49. 49
    50. 50
    51. 51
    52. 52
    53. 53
    54. 54
    55. 55
    56. 56
    57. 57
    58. 58
    59. 59
    60. 60
    61. 61
    62. 62
    63. 63
    64. 64
    65. 65
    66. 66
    67. 67
    68. 68
    69. 69
    70. 70
    71. 71
    72. 72
    73. 73
    74. 74
    75. 75
    76. 76
    77. 77
    78. 78
    79. 79
    80. 80
    81. 81
    82. 82
    83. 83
    84. 84
    85. 85
    86. 86
    87. 87
    88. 88
    89. 89
    90. 90
    91. 91
    92. 92
    93. 93
    94. 94
    95. 95
    96. 96
    97. 97
    int main( void )
    {
        fraction f1, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12, f13, f14, f15;
        fraction t1f1, t1f2, t1f3, t1f4, t1f5, t1f6, t1f7, t1f8, t1f9, t1f10, t1f11, t1f12, t1f13, t1f14, t1f15;
        fraction t2f1, t2f2, t2f3, t2f4, t2f5, t2f6, t2f7, t2f8, t2f9, t2f10, t2f11, t2f12, t2f13, t2f14, t2f15;
        fraction t3f1, t3f2, t3f3, t3f4, t3f5, t3f6, t3f7, t3f8, t3f9, t3f10, t3f11, t3f12, t3f13, t3f14, t3f15;
        fraction t4f1, t4f2, t4f3, t4f4, t4f5, t4f6, t4f7, t4f8, t4f9, t4f10, t4f11, t4f12, t4f13, t4f14, t4f15;
        fraction t5f1, t5f2, t5f3, t5f4, t5f5, t5f6, t5f7, t5f8, t5f9, t5f10, t5f11, t5f12, t5f13, t5f14, t5f15;
        fraction t6f1, t6f2, t6f3, t6f4, t6f5, t6f6, t6f7, t6f8, t6f9, t6f10, t6f11, t6f12, t6f13, t6f14, t6f15;
        fraction t7f1, t7f2, t7f3, t7f4, t7f5, t7f6, t7f7, t7f8, t7f9, t7f10, t7f11, t7f12, t7f13, t7f14, t7f15;
        fraction t8f1, t8f2, t8f3, t8f4, t8f5, t8f6, t8f7, t8f8, t8f9, t8f10, t8f11, t8f12, t8f13, t8f14, t8f15;
        fraction t9f1, t9f2, t9f3, t9f4, t9f5, t9f6, t9f7, t9f8, t9f9, t9f10, t9f11, t9f12, t9f13, t9f14, t9f15;
        fraction t10f1, t10f2, t10f3, t10f4, t10f5, t10f6, t10f7, t10f8, t10f9, t10f10, t10f11, t10f12, t10f13, t10f14, t10f15;
        fraction t11f1, t11f2, t11f3, t11f4, t11f5, t11f6, t11f7, t11f8, t11f9, t11f10, t11f11, t11f12, t11f13, t11f14, t11f15;
        fraction t12f1, t12f2, t12f3, t12f4, t12f5, t12f6, t12f7, t12f8, t12f9, t12f10, t12f11, t12f12, t12f13, t12f14, t12f15;
        fraction t13f1, t13f2, t13f3, t13f4, t13f5, t13f6, t13f7, t13f8, t13f9, t13f10, t13f11, t13f12, t13f13, t13f14, t13f15;
        fraction t14f1, t14f2, t14f3, t14f4, t14f5, t14f6, t14f7, t14f8, t14f9, t14f10, t14f11, t14f12, t14f13, t14f14, t14f15;
        fraction t15f1, t15f2, t15f3, t15f4, t15f5, t15f6, t15f7, t15f8, t15f9, t15f10, t15f11, t15f12, t15f13, t15f14, t15f15;
        fraction current;
        current.getnum( 1 );
        int den( 0 );
        int num ( 1 );
        do
        {
            cout << "Enter den: ";
            cin >> den;
            if( den > 16 )
            {
                cout << "Very big den! Try again!" << endl;
                continue;
            }
            if( den < 2 )
            {
                cout << "Very small den! Try again!" << endl;
                continue;
            }
            current.getden( den );
        }
        while( den > 16 || den < 2 );
    //////////////////////////////////////////////////////////////////////////////////////////////
        cout << endl;
        cout << "----------------------------------------------------------------------" << endl;
        f1 = current;
        f1.showfrac( ); cout << " ";
        current.getnum( ++num );
        if( den > num )
        {
            f2 = current;
            f2.lowterms( );
            f2.showfrac( ); cout << " ";
        }
        current.getnum( ++num );
        if( den > num )
        {
            f3 = current;
            f3.lowterms( );
            f3.showfrac( ); cout << " ";
        }
        current.getnum( ++num );
        if( den > num )
        {
            f4 = current;
            f4.lowterms( );
            f4.showfrac( ); cout << " ";
        }
        current.getnum( ++num );
        if( den > num )
        {
            f5 = current;
            f5.lowterms( );
            f5.showfrac( ); cout << " ";
        }
        current.getnum( ++num );
        if( den > num )
        {
            f6 = current;
            f6.lowterms( );
            f6.showfrac( ); cout << " ";
        }
        current.getnum( ++num );
        if( den > num )
        {
            f7 = current;
            f7.lowterms( );
            f7.showfrac( ); cout << " ";
        }
        current.getnum( ++num );
        if( den > num )
        {
            f8 = current;
            f8.lowterms( );
            f8.showfrac( ); cout << " ";
        }
        current.getnum( ++num );
        if( den > num )
        {
            f9 = current;

    Выполнение задания. Массивы? Проверка ввода? Не, не слышали!

    BaronDeLotion, 07 Сентября 2016

    Комментарии (15)
  5. C++ / Говнокод #21125

    +26

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    for(devIndex=0;SetupDiEnumDeviceInfo(devs,devIndex,&devInfo);devIndex++) {
    
            if(doSearch) {
                for(argIndex=skip,match=FALSE;(argIndex<argc) && !match;argIndex++) {
                    TCHAR devID[MAX_DEVICE_ID_LEN];
                    LPTSTR *hwIds = NULL;
                    LPTSTR *compatIds = NULL;
                    //
                    // determine instance ID
                    //
                    if(CM_Get_Device_ID_Ex(devInfo.DevInst,devID,MAX_DEVICE_ID_LEN,0,devInfoListDetail.RemoteMachineHandle)!=CR_SUCCESS) {
                        devID[0] = TEXT('\0');
                    }
    ...
    }

    Лучший стиль форматирования кода от индусов из MS.
    Код взят из этого файла:
    https://github.com/Microsoft/Windows-driver-samples/blob/master/setup/devcon/devcon.cpp
    В других файлах код примерно аналогичный.

    demoth, 07 Сентября 2016

    Комментарии (13)
  6. C++ / Говнокод #21054

    +410

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    26. 26
    27. 27
    28. 28
    29. 29
    30. 30
    31. 31
    32. 32
    33. 33
    34. 34
    35. 35
    36. 36
    37. 37
    38. 38
    39. 39
    40. 40
    41. 41
    42. 42
    43. 43
    44. 44
    45. 45
    46. 46
    47. 47
    48. 48
    49. 49
    50. 50
    CBroadcastPropPP::CBroadcastPropPP()
    {
    m_bAdminMode = FALSE;
    
    m_aProps.Add(new CRPProp_01);
    m_aProps.Add(new CRPProp_02);
    m_aProps.Add(new CRPProp_021);
    m_aProps.Add(new CRPProp_022);
    m_aProps.Add(new CRPProp_03);
    m_aProps.Add(new CRPProp_05);
    m_aProps.Add(new CRPProp_06);
    m_aProps.Add(new CRPProp_07);
    }
    
    #define PPPos_Dir 0
    #define PPPos_Recursive 1
    #define PPPos_Masks 2
    #define PPPos_MaxSize 3
    #define PPPos_Archive 4
    #define PPPos_Subject 5
    #define PPPos_Types 6
    #define PPPos_MaxRcpt 7
    #define PPPos_BCC 8
    
    void CBroadcastPropPP::Initialize(IRegistrato​r* pRegistrator)
    {
    AFX_MANAGE_STATE(AfxGetStaticModuleState(​ ));
     m_pRegistrator=pRegistrator;
    
    ((CRPProp_01*)(m_aProps[PPPos_Dir]))->_I​nitialize(m_pRegistrator->m_sStartupPath,​ m_pRegistrator);
    ((CRPProp_02*)(m_aProps[PPPos_Recursive]​))->_Initialize(m_pRegistrator->m_sStart​upPath, m_pRegistrator);
    ((CRPProp_021*)(m_aProps[PPPos_Masks]))-​>_Initialize(m_pRegistrator->m_sStartupP​ath, m_pRegistrator);
    ((CRPProp_022*)(m_aProps[PPPos_MaxSize])​)->_Initialize(m_pRegistrator->m_sStartu​pPath, m_pRegistrator);
    ((CRPProp_03*)(m_aProps[PPPos_Archive]))​->_Initialize(m_pRegistrator->m_sStartup​Path, m_pRegistrator);
    ((CRPProp_05*)(m_aProps[PPPos_Types]))->_​Initialize(&m_pRegistrator->m_DB,m_pRegistrator->m_s​StartupPath);
    ((CRPProp_06*)(m_aProps[PPPos_MaxRcpt]))​->_Initialize(m_pRegistrator->m_sStartup​Path, m_pRegistrator );
    ((CRPProp_07*)(m_aProps[PPPos_BCC]))->_I​nitialize(m_pRegistrator->m_sStartupPath,​ m_pRegistrator );
    }
    
    CBroadcastPropPP::~CBroadcastPropPP()
    {
    delete (CRPProp_01*)m_aProps[PPPos_Dir];
    delete (CRPProp_02*)m_aProps[PPPos_Recursive];
    delete (CRPProp_021*)m_aProps[PPPos_Masks];
    delete (CRPProp_022*)m_aProps[PPPos_MaxSize];
    delete (CRPProp_03*)m_aProps[PPPos_Archive];
    delete (CRPProp_05*)m_aProps[PPPos_Types];
    delete (CRPProp_06*)m_aProps[PPPos_MaxRcpt];
    delete (CRPProp_07*)m_aProps[PPPos_BCC];
    }

    «Вот что бывает, когда пишешь на C++, не зная, зачем нужны виртуальные деструкторы...

    классы CRPProp_0n - производные от общего базового класса. Вроде задумка неплохая, можно работать с их массивом, удобно. Но видимо, что-то не заладилось, почему-то их методы не вызывались (про виртуальные функции разработчик не знал)... И тут на выручку эмо-кодеру пришло приведение типов! Правда, про работу с массивом в цикле пришлось забыть...»


    Источник: http://emo-coders.livejournal.com/59977.html

    inkanus-gray, 01 Сентября 2016

    Комментарии (20)
  7. C++ / Говнокод #20972

    0

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    26. 26
    27. 27
    28. 28
    29. 29
    30. 30
    31. 31
    32. 32
    33. 33
    34. 34
    35. 35
    36. 36
    37. 37
    38. 38
    39. 39
    const int DD_GOOD = 1;
    const int DD_BAD = 2;
    const int DD_BAD_VERT = 3;
    auto segStatus = [&DD_GOOD, &DD_BAD, &DD_BAD_VERT](SomeClass* seg, EXTR ext, coord pickPt, double pickElev) -> int
    {
    	Pt&			pt = seg->ExtremePt(ext);
    	Line&	line = seg->ExtremeLn(ext);
    	coord			btPt = seg->GetExtremeWallPos(ext);
    
    	if (pt.GetCoord() != pickPt && btPt != pickPt)
    	{
    		return DD_BAD;
    	}
    
    	if (pt.pairGuid == GUID_NULL && EQ(pt.GetHeight(), pickElev))
    	{
    		return DD_GOOD;
    	}
    
    	if (!line.IsNonVert())
    	{
    		return DD_BAD;
    	}
    
    	double e1 = line.m_startPt.GetHeight();
    	double e2 = line.m_endPt.GetHeight();
    	
    	if (e1 < e2 && e1 < pickElev && pickElev < e2)
    	{
    		return DD_GOOD;
    	}
    	
    	if (e2 < e1 && e2 < pickElev && pickElev < e1)
    	{
    		return DD_GOOD;
    	}
    	
    	return DD_BAD_VERT;
    };

    Когда не умеешь пользоваться энумами.

    yog_muskrat, 26 Августа 2016

    Комментарии (12)
  8. C++ / Говнокод #20957

    +918

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    #include <iostream>
    
    template<typename T>
    struct A {
      typedef int R();
    
      template<typename U>
      static U *f(int) { 
        return 0; 
      }
    
      static int f() { 
        return 0;
      }
    };
    
    template<typename T>
    bool g() { A<T> a; return !(typename A<T>::R*)a.f<int()>(0); }
    template<typename T>
    bool h() { A<T> a; return !(         A<T>::R*)a.f<int()>(0); }
    
    int main() {
      std::cout << g<void>() << f<void>() << std::endl;
    }

    Как можно было придумать такой синтаксис :(

    Bobik, 25 Августа 2016

    Комментарии (6)
  9. C++ / Говнокод #20947

    +2302

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    http://govnokod.ru/20924
    
    Запрашиваемая страница не найдена!
    
    Возможно, её и не было никогда

    http://dump.bitcheese.net/files/pimarut/%D0%93%D0%BE%D0%B2%D0%BD%D0%BE%D0%BA%D0%BE%D0%B4_%2320924_%E2%80%94_C___%E2%80%94_%D0%93%D0%BE%D0%B2%D0%BD%D0%BE%D0%BA%D0%BE%D0%B4.%D1%80%D1%83.html
    но бекап я сделал, так что хуй вам. Я требую продолжения банкета.

    j123123, 24 Августа 2016

    Комментарии (60)
  10. C++ / Говнокод #20930

    +458

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    9. 9
    tinyxml2::XMLDocument doc;
        doc.Parse(xhtml.c_str());//парсируем до конца
    
        tinyxml2::XMLElement* xml_element =
            doc.FirstChildElement("html")->FirstChildElement("body")->FirstChildElement("div")->
                NextSiblingElement("div")->NextSiblingElement("div")->FirstChildElement("div")->
                    NextSiblingElement("div")->FirstChildElement("div")->NextSiblingElement("div")->
                        FirstChildElement("div")->FirstChildElement("div")->NextSiblingElement("div")->
                            FirstChildElement("form");

    jangolare, 23 Августа 2016

    Комментарии (18)