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

    +1002

    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
    //pugiXML.cpp:
    template <bool _1, bool _2, bool _3, bool _4> struct opt4_to_type
    	{
    		static const bool o1;
    		static const bool o2;
    		static const bool o3;
    		static const bool o4;
    	};
    
    	template <bool _1, bool _2, bool _3, bool _4> const bool opt4_to_type<_1, _2, _3, _4>::o1 = _1;
    	template <bool _1, bool _2, bool _3, bool _4> const bool opt4_to_type<_1, _2, _3, _4>::o2 = _2;
    	template <bool _1, bool _2, bool _3, bool _4> const bool opt4_to_type<_1, _2, _3, _4>::o3 = _3;
    	template <bool _1, bool _2, bool _3, bool _4> const bool opt4_to_type<_1, _2, _3, _4>::o4 = _4;
    //...
    case 0:  return strconv_attribute_t(s, end_quote, opt4_to_type<0, 0, 0, 0>());
    		case 1:  return strconv_attribute_t(s, end_quote, opt4_to_type<0, 0, 0, 1>());
    		case 2:  return strconv_attribute_t(s, end_quote, opt4_to_type<0, 0, 1, 0>());
    		case 3:  return strconv_attribute_t(s, end_quote, opt4_to_type<0, 0, 1, 1>());
    		case 4:  return strconv_attribute_t(s, end_quote, opt4_to_type<0, 1, 0, 0>());
    		case 5:  return strconv_attribute_t(s, end_quote, opt4_to_type<0, 1, 0, 1>());
    //...
    		case 14: return strconv_attribute_t(s, end_quote, opt4_to_type<1, 1, 1, 0>());
    		case 15: return strconv_attribute_t(s, end_quote, opt4_to_type<1, 1, 1, 1>());
    //...
    inline xml_parse_result make_parse_result(xml_parse_status status, unsigned int offset, unsigned int line)
    	{
    		xml_parse_result result = {status, offset, line};
    		return result;
    	}
    
    //pugixpath.cpp:
    block = static_cast<memory_block*>(operator new(size + sizeof(memory_block) - xpath_memory_block_size));

    PugiXML

    Говногость, 16 Апреля 2012

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

    +155

    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
    int main() {
        
        float a = 3.14;
        
        asm volatile (
                        "decl   %%esp"                      "\n\t"
                        "movb   $0, (%%esp)"                "\n\t"
                        "decl   %%esp"                      "\n\t"
                        "movb   $'\n', (%%esp)"             "\n\t"
                        "movl   $32, %%eax"                 "\n"
            "label0:"                                       "\n\t"
                        "shrl   %[A]"                       "\n\t"
                        "decl   %%esp"                      "\n\t"
                        "jc     label1"                     "\n\t"
                        "movb   $'0', (%%esp)"              "\n\t"
                        "jmp    label2"                     "\n"
            "label1:"                                       "\n\t"
                        "movb   $'1', (%%esp)"              "\n\t"
            "label2:"                                       "\n\t"
                        "decl   %%eax"                      "\n\t"
                        "cmpl   $0, %%eax"                  "\n\t"
                        "ja     label0"                     "\n\t"
                                                            "\n\t"
                        "pushl  %%esp"                      "\n\t"
                        "call   printf"                     "\n\t"
                                                            "\n\t"
                        "addl   $38, %%esp"                 "\n"
            
            : /* no output registers */
            : [A] "r" (a)
            : "%esp", "%eax"
        );
        
        return 0;
    }

    float > bin

    igoreknog, 16 Апреля 2012

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

    +1002

    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
    void TExternalIOBuffer::swap(TExternalIOBuffer& Buffer)
    {
    	ASSERT(typeid(Buffer)==typeid(TExternalIOBuffer));
    	const TExternalIOBuffer CurrentBuffer=*this;
    	const TExternalIOBuffer OtherBuffer=Buffer;
    	Buffer.~TExternalIOBuffer();
    	::new((void*)&Buffer) TExternalIOBuffer(CurrentBuffer);
    	this->~TExternalIOBuffer();
    	::new((void*)this) TExternalIOBuffer(OtherBuffer);
    };
    
    const TExternalIOBuffer& TExternalIOBuffer::operator=(const TAbstractIOBuffer& Buffer)
    {
    	this->~TExternalIOBuffer();
    	::new((void*)this)TExternalIOBuffer(Buffer);
    	return *this;
    };

    Большой проект, попало в релиз.

    Говногость, 16 Апреля 2012

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

    +1004

    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
    long base64::rlong (char * source)
    {
        long res = 0;
        for (int i = 0; i < 4; i++) ((char *) &res)[3 - i] = source[i];
        return res;
    }
    
    void base64::encode (char * source, char * dest)
    {
        char base[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
        int n = 0;
        for (int nd = 0; nd < ceil(4*((double)strlen(source))/3); nd++)
            dest[n++] = base[rlong(&source[((nd >> 2) << 2)*3 >> 2]) >> (26 - 6*(nd - ((nd >> 2) << 2))) & 0x3F]; 
        for (int i = 0; i < ((int) ceil(((double)n)/4) << 2) - n; i++) dest[n++] = '=';
        dest[n] = 0;
    }

    Ответ преподу по c++. Переводстроки в base64.

    antonymus, 14 Апреля 2012

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

    +119

    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
    if(bCanPut)
    {
    	
    	m_RealTexts[nIndex].txtStartPt.x = ptStandard.x + (szStandard.cx-szTxtDC.cx)/2.0;
    	m_RealTexts[nIndex].txtStartPt.y = ptStandard.y + (szStandard.cy-szTxtDC.cy)/2.0;
    	m_RealTexts[nIndex].txtSize = szTxtDC;
    	m_RealTexts[nIndex].txtMovePt.x = 0.0 - (szStandard.cx-szTxtDC.cx)/2.0;
    	m_RealTexts[nIndex].txtMovePt.y = 0.0 - (szStandard.cy-szTxtDC.cy)/2.0;
    }
    else
    {
    	
    	m_RealTexts[nIndex].txtStartPt.x = ptStandard.x + (szStandard.cx-szTxtDC.cx)/2.0;
    	m_RealTexts[nIndex].txtStartPt.y = ptStandard.y + (szStandard.cy-szTxtDC.cy)/2.0;
    	m_RealTexts[nIndex].txtSize = szTxtDC;
    	m_RealTexts[nIndex].txtMovePt.x = 0.0 - (szStandard.cx-szTxtDC.cx)/2.0;
    	m_RealTexts[nIndex].txtMovePt.y = 0.0 - (szStandard.cy-szTxtDC.cy)/2.0;
    }

    someone, 12 Апреля 2012

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

    +154

    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
    #include "stdafx.h"
    #include "expression.h"
    #include <vector>
    
    int _tmain(int argc, _TCHAR* argv[]) {
    //Инициализация
    	std::vector<expression> arrayOfExpressions;
    	std::string inputString;
    //Ввод количества выражений
    	printf( "Enter expressions count: " );
    	int countOfExpressions = 0;
    	scanf( "%d", &countOfExpressions );
    //Ввод самих выражений
    	for ( int i = 1; i <= countOfExpressions; i++ ) {
    		printf( "Enter expression: " );
    		scanf( "%s", inputString );
    		arrayOfExpressions.push_back( expression( inputString ) );
    	}
    //Подсчёт операторов
    	int total = 0;
    	for (int i = 0; i < arrayOfExpressions.size(); i++)
    		total += arrayOfExpressions.at(i).operatorsCount();
    	printf( "Total operators = %d", total );
    //Освобождение памяти
    	arrayOfExpressions.erase(arrayOfExpressions.begin(),arrayOfExpressions.end());
    	return 0;
    }

    Один из уже известных вам студентов написал вот это. Вроде получше.

    Fai, 11 Апреля 2012

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

    +159

    1. 1
    2. 2
    3. 3
    4. 4
    bool THotKeysRepository::TKeyCombination::operator<( const TKeyCombination& y ) const
    {
    	return this->_AltKeyState<y._AltKeyState && this->_ScanCode<y._ScanCode;
    }

    Говногость, 11 Апреля 2012

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

    +989

    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
    98. 98
    99. 99
    stek* getLast(){
    	stek* result = first;
    	while (!isLast(*result)){
    		result = result->next;
    	}
    	return result;
    }
    void push( char* string ){
    	stek* anew = new stek;
    	anew->string = string;
    	anew->next = NULL;
    	anew->first = first;
    	getLast()->next = anew;
    }
    void printList(){
    	if (first != NULL){
    		stek* element = first;
    		puts( element->string );
    		while (!isLast(*element)){
    			element = element->next;
    			puts( element->string );
    		}
    	}
    	else{
    		puts( "List is empty" );
    	}
    }
    stek* getPrev( stek* element ){
    	stek* result = first;
    	while (result->next != element){
    		result = result->next;
    	}
    	return result;
    }
    void changeFirstInList( stek* newFirst ){
    	stek* element = first;
    	while (element != NULL){
    		element->first = newFirst;
    		element = element->next;
    	}
    }
    void deleteElement( stek* element )
    {
    	if ( element->first == element ){
    		first = element->next;
    		changeFirstInList( first );
    	}
    	else{
    		stek* prev = getPrev( element );
    		stek* next = element -> next;
    		prev->next = next;
    	}
    }
    void deleteElements( int length ){
    	stek* element = first;
    	while (element != NULL){
    		stek* next = element->next;
    		if (strlen(element->string) < length) {
    		    deleteElement( element );
    		}
    		element = next;
    	}
    }
    int _tmain(int argc, _TCHAR* argv[]){ 
    	char *token;
    	char st1[80];
    	int minLength = 4;
    	int n=0;
    	
    	printf("Enter string: ");
    	gets( st1 );
    	printf("Enter minimal length: ");
    	scanf( "%d", &minLength );
    
    	first=NULL;
    	first=new stek;
    	first->next=NULL;
    	first->first=first;
      token=strtok(st1," ");
      first->string=token;
      token=strtok(NULL," ");
      while( token != NULL){ 
    	push(token);;
    	token=strtok(NULL," ");
      }
      stek* element = first;
      while (element != NULL){
    	stek* next = element->next;
    	if (strlen(element->string)<3) n++;
    	element = next;
      }
      puts("Initial stack:");
      printList();
      deleteElements( minLength );
      printf("Slov dlinoi less than 3: %d\n",n);
      puts("After deleting:");
      printList();
      getch();
    }

    Лабораторная работа, написанная двумя студентами первого курса. Задание: "Дана строка 80 символов, разбить её на слова (разделитель - пробел), удалить слова меньше опр. длины и вывести количество слов с длиной меньше 3-ех".
    Почти каждая строчка в main'e - перл.
    З.Ы. Форматирование кода тоже доставляет.

    Fai, 10 Апреля 2012

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

    +154

    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
    #include <iostream>
    #include <stdio.h>
     
    void foo(const long) { std::cout << "long" << std::endl; }
     
    template<typename _type_>
    void omg()
    {
            short i = 0;
            foo(i);
    }
     
    void foo(const short) { std::cout << "short" << std::endl; }
     
    int main(int, char*[])
    {
      omg<int>();
     
      getchar();
      return 0;
    }

    код для гцц -> http://ideone.com/mifTV

    вопрос, что выдаст говностудия?

    связанно с тем, что говностудия не ищет независимые типы использованные в шаблоне на этапе определения. она их ищет только в точке конкретизации шаблона. гцц связывает независимые типы в шаблоне на этапе определения шаблона

    З.Ы. ответ на http://govnokod.ru/9885#comment134160

    Govnoeb, 09 Апреля 2012

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

    +194

    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
    if(!menu_font||!oboima_text||!info||!infoR||!infoD||!infoBR||
          !oblaka1_tex||!fon1_tex||!fon2_tex||!fon3_tex||
          !galka_tex||!galka_menu_tex||!strelka_menu_tex||!strelka_menu_D_tex||
          !znak_myasnik_tex||!znak_strelok_tex||!znak_razrushitel_tex||!znak_tehnik_tex||
          !status_opit_tex||!status_udar_tex||!status_status_tex||!opit_okno_vibora_tex||
          !okno_lvl_progress_tex||!okno_lvl_progress_red_tex||!okno_lvl_progress_green_tex||!okno_lvl_polzunok_tex||
          !snd||!ak_reload1||!ak_reload2||!pm_fire||!pm_reload1||!pm_reload2||
          !pp19_fire||!pp19_reload1||!pp19_reload2||!fn_f2000_fire||!tt_fire||
          !mac_fire||!mac_reload1||!mac_reload2||!webley_fire||!webley_reload1||!webley_reload2||!milkor_fire||
          !fn_five_seven_fire||!winch_fire||!drob_reload1||!drob_pompa||!vzriv_grena1||
          !rocket_fire||!rocket2_fire||!rocket_polet||!rocket2_polet||
          !myaso_upalo1||!myaso_upalo2||!myaso_upalo3||!myaso_upalo4||!myaso_upalo5||!myaso_upalo6||!myaso_upalo7||
          !myaso_upalo8||
          !myaso_razriv_user1||!myaso_razriv_user2||
          !menu_sound||!menu_choose||
          !shot1||!headshot1||!headshot2||!headshot3||!headshot4||!headshot5||!headshot6||!headshot7||!headshot8||
          !ssik1||!ssik2||!ssik3|!ssik4||
          !ptenec_death1||
          !ak||!ak2||!ak_upgraded||!ak2_upgraded||!w_pm_tex||!w_pp19_vityaz_tex||!w_fn_f2000_tex||!w_fn_f2000_upgraded_tex||
          !w_tt_tex||!w_rpk_tex||!w_mac_tex||
          !w_winchester_tex||!w_winchester_anime_tex||!w_rpk47_tex||!w_glok_tex||!w_glok2_tex||!w_rgd5_tex||!w_milkor_tex||
          !w_panzer_tex||!w_panzer_out_tex||!w_webley_tex||!w_fn_five_seven_tex||!w_granata_podstvol_tex||!w_granata_panzer_tex||
          !w_qlz87_pushka_tex||!w_qlz87_trenoga_tex||!katana_udar_sleva_tex||
          !blood1_tex||!blood2_tex||!blood3_tex||!blood_shot1_tex||
          !blood_plyam1_tex||!blood_plyam2_tex||!blood_plyam3_tex||!blood_luzha1_tex||
          !blood_myaso1_tex||!blood_myaso2_tex||!blood_myaso3_tex||!blood_myaso4_tex||!blood_myaso5_tex||
          !blood_zayac_noga1_tex||!blood_zayac_noga2_tex||!blood_zayac_noga3_tex||!blood_zayac_noga4_tex||
          !blood_zayac_rebra1_tex||!blood_zayac_rebra2_tex||
          !blood_vzriv1_a_tex||!blood_vzriv1_b_tex||!blood_vzriv1_c_tex||!blood_vzriv1_d_tex||!blood_vzriv1_e_tex||
          !blood_vzriv1_e2_tex||
          !player1_myasnik_gogranata_ruka1_tex||!player1_myasnik_gogranata_ruka2_tex||
          !player1_strelok_gogranata_ruka1_tex||!player1_strelok_gogranata_ruka2_tex||
          !player1_razrushitel_gogranata_ruka1_tex||!player1_razrushitel_gogranata_ruka2_tex||    
          !player1_tehnik_gogranata_ruka1_tex||!player1_tehnik_gogranata_ruka2_tex||
          !player1_myasnik_tex||!player1_strelok_tex||!player1_razrushitel_tex||!player1_tehnik_tex||
          !player1_myasnik_ruka1_udar_sleva_tex||!player1_strelok_ruka1_udar_sleva_tex||
          !player1_razrushitel_ruka1_udar_sleva_tex||!player1_tehnik_ruka1_udar_sleva_tex||
          !player1_myasnik_ruka1_pistol_tex||!player1_strelok_ruka1_pistol_tex||
          !player1_razrushitel_ruka1_pistol_tex||!player1_tehnik_ruka1_pistol_tex||
          !player1_myasnik_ruka1_vintovka_tex||!player1_strelok_ruka1_vintovka_tex||
          !player1_razrushitel_ruka1_vintovka_tex||!player1_tehnik_ruka1_vintovka_tex||
          !player1_myasnik_ruka1_winch_tex||!player1_strelok_ruka1_winch_tex||
          !player1_razrushitel_ruka1_winch_tex||!player1_tehnik_ruka1_winch_tex||
          !player2_strelok_tex||!player2_gogranata_ruka1_tex||!player2_gogranata_ruka2_tex||
          !player2_strelok_ruka1_udar_sleva_tex||!player2_strelok_ruka1_vintovka_tex||!player2_strelok_ruka1_pistol_tex||
          !zayac_go_tex||!zayac_uhi_k_tex||!zayac_uhi_s_tex||!zayac_uhi_tex||
          !zayac_boshka_tex||!zayac_boshka_bezuh_tex||
          !volk_go_tex||!volk_trup1_a_tex||!volk_trup1_b_tex||!volk_trup1_c_tex||
          !medved_go_tex||!medved_boshka1_tex||

    http://www.gamedev.ru/projects/forum/?id=160897
    ЩИ!!!! ЗАЛЕЙ ВЕСЬ ЭКРАН КРОВЬЮ УВИДЕВ ИСХОДНЫЙ КОД

    TarasB, 09 Апреля 2012

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