1. Лучший говнокод

    В номинации:
    За время:
  2. C++ / Говнокод #17786

    +54

    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
    #include <iostream>
    using namespace std;
    
    struct Foo
    {
    	int i[0];
    };
    
    int main() {
    	// your code goes here
    	Foo f1;
    	Foo f2[5];
    	cout << sizeof(f1) << endl;
    	cout << sizeof(f2) << endl;
    	return 0;
    }

    http://rextester.com/NAA5246
    http://rextester.com/GKLFG82436
    http://rextester.com/SSZ22454
    http://rextester.com/ZEY11320

    DlangGovno, 14 Марта 2015

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

    +68

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    int a, b ;
    //some code
    int numCount = 0;
    while ((a + numCount++) < b)    // посчитать кол-во чисел между a и b, включая a и b
       ;

    это великолепно!

    Croessmah, 11 Марта 2015

    Комментарии (12)
  4. Python / Говнокод #17738

    −113

    1. 1
    escape_cats = [cat_id for cat_id, values in cats.iteritems() if any([values[1] == supercat or cat_id == supercat for supercat in escape_supercats])]

    Избегание котов.

    pushistayapodmyshka, 06 Марта 2015

    Комментарии (12)
  5. Куча / Говнокод #17714

    +131

    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
    elseif selectedObj::mouthOnMenuRect then
      if dir == "left" then
        inv = true
        changeMouth()
      elseif dir == "right" then
        inv = false
        changeMouth()
      end
    elseif selectedObj::eyesOnMenuRect then
      if dir == "left" then
        inv = true
        changeEyes()
      elseif dir == "right" then
        inv = false
        changeEyes()
      end
    elseif

    Вступительная заставка к фильму "Добро пожаловать в рай", промелькнуло с десяток таких вот блоков "elseif selectedObj::чтоТоТамOnMenuRect".
    В начале фильма под сеансом видеосвязи с аналоговыми помехами закольцевали фрагмент телефонного справочника на си с полотнами printf.
    Где-то в середине в консольном окошке с заголовком "DATABASE_QUERY" продемонстрировали код функции groups_alloc из ядра linux, а чуть позже - groups_from_user и groups_sort из того же файла.
    Между делом, хакер отличается от других тем, что у него не терминал, а SECURE_TERMINAL, сам он носит ублюдошные очки в толстой оправе, а код в терминале тот же сишный, но красного цвета вместо зеленого.
    Под конец на "главный сервер" заливали виндовый батничек, над которым явно работали больше, чем над сценарием фильма. Нагуглился исходник батничка: http://www.wikihow.com/Make-a-Prank-Virus-(Windows)

    Xom94ok, 01 Марта 2015

    Комментарии (12)
  6. Куча / Говнокод #17688

    +133

    1. 1
    2. 2
    HTTP referer (originally a misspelling of referrer) is an HTTP header field that identifies the address of the webpage
    (i.e. the URI or IRI) that linked to the resource being requested.

    Originally a misspelling of referrer...

    bormand, 24 Февраля 2015

    Комментарии (12)
  7. Си / Говнокод #17685

    +137

    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
    #include <time.h>
    
    
    int rrand(int start, int end)
    {
    	int range=end-start+1;
    	int speed=1;
    	int base=0;
    	int rez=start;
    	if(range>200) speed=range/100;
    	while(range>=0)
    	{
    		srand(clock());
    		if(rand()%2) base=base+speed+1;
    		else base--;
    		rez=rez+base;
    		rez=(rez < start)? end-rez : rez;
    		rez=(rez > end)? (rez%end)+start : rez;
    		range=range-speed;
    	}
    	return rez;
    }

    случайные числа в определенном диапазоне...

    pl7ofit, 24 Февраля 2015

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

    +160

    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
    foreach (scandir(DIR.'app'.SLASH.'lib') as $filename) {
        $path = DIR.'app'.SLASH.'lib'.SLASH.$filename;
        if (is_file($path) && substr($filename,strlen($filename)-4,4)=='.php') {
            require_once($path);
        }
    }
    foreach (scandir(DIR.'app'.SLASH.'models') as $filename) {
        $path = DIR.'app'.SLASH.'models'.SLASH.$filename;
        if (is_file($path) && substr($filename,strlen($filename)-4,4)=='.php') {
            require_once($path);
        }
    }
    foreach (scandir(DIR.'app'.SLASH.'ext') as $filename) {
        $path = DIR.'app'.SLASH.'ext'.SLASH.$filename;
        if (is_file($path) && substr($filename,strlen($filename)-4,4)=='.php') {
            require_once($path);
        }
    }

    Начался разбор проблемы со слов заказчика - "сайт долго грузится"

    Crawdaunt, 22 Февраля 2015

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

    +108

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    void Data3Fill(string _TownCheck, string _StreetCheck, string _HouseCheck, string _FlatCheck, string _BloodCheck,
    string _InsuranceCheck, string _EndPolCheck, string _DateFutureCheck, string _DoctorCheck, string _DiagnosisCheck, string _ComplaintsCheck, string _VichCheck, string _CancerCheck, string _SurnameCheck, string _NameCheck, string _MidnameCheck,
    string _SexCheck, string _StatusCheck, string _HighStatusCheck)
    {
    ...
    }

    Одному моему другу такой подход кажется нормальным.

    LoveSong, 01 Февраля 2015

    Комментарии (12)
  10. Си / Говнокод #17553

    +130

    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
    char* obrab_stroki(char*, int);
    int move(char*);
    int action_register(char*);
    int speed(char*);
    int condition(char*);
    
    char answer1[25];
    uint8_t Output[512];
    uint32_t number_for_output=16;
    typedef struct { char *name; uint8_t adress; } struct_label;
    typedef struct { char *name; uint8_t adress; } struct_goto_label;
    //----------------------------------------------------------------------------------------
    while (strcmp(qwerty[++string_count],""))
    	{
    		str=obrab_stroki(qwerty[string_count], 0);
    		printf("s:%s\n",str);
    		
    		if (!strcmp(qwerty[string_count]+strlen(qwerty[string_count])-1,"{")) fig_skob++;
    		if (!strcmp(qwerty[string_count]+strlen(qwerty[string_count])-1,"}")) fig_skob--;				
    		if (!strcmp(qwerty[string_count]+strlen(qwerty[string_count])-1,"{") && !strcmp(str,"if")) { fig_skob_if++; adres_return[fig_skob_if]=number_for_output+3; }
    		if (!strcmp(qwerty[string_count]+strlen(qwerty[string_count])-1,"}") && fig_skob_if>0) { Output[adres_return[fig_skob_if]]=number_for_output; fig_skob_if--;}
    		if (fig_skob==0)
    		{
    			Output[number_for_output++]=0;
    			Output[number_for_output++]=0;
    		}
    
    		if (!strcmp(qwerty[string_count]+strlen(qwerty[string_count])-1,":")) 
    		{ 
    			label[number_label].name=qwerty[string_count];
    			label[number_label++].adress = number_for_output;
    			continue;
    		}				
    //-------------------------------------------------------------------------------------------
    if (!strcmp(str,"r")) if (action_register(qwerty[string_count]) == 1) {printf("ERROR in string: %d", string_count); return 1;} else continue;
    		if (!strcmp(str,"move")) if (move(qwerty[string_count]) == 1) {printf("ERROR in string: %d", string_count); return 1;} else continue;
    		if (!strcmp(str,"speed")) if (speed(qwerty[string_count]) == 1) {printf("ERROR in string: %d", string_count); return 1;} else continue;
    		if (!strcmp(str,"if")) if (condition(qwerty[string_count]) == 1) {printf("ERROR in string: %d", string_count); return 1;} else continue;
    		
    //-----------------------------------------------------------------------------------------
    char* obrab_stroki(char* qwerty, int i)
    {
    	int count;
    	char asnwer1[25];
    
    	for (count=0; (qwerty[count+i]<='z' && qwerty[count+i]>='a') || (qwerty[count+i]<='Z' && qwerty[count+i]>='A'); count++)
    	{
    		answer1[count]=qwerty[count+i];
    	}
    	answer1[count]='\0';
    
    	return answer1;
    }//тут как бы нет ошибок =)
    
    //----------------------------------------------------------------------------------------------
    if (qwerty[i]=='-')
    	{
    		if (qwerty[i+1]=='1' && qwerty[i+2]=='0')
    			{
    				Output[number_for_output++]=answer|MOTOR_SPEC_SPEED_DEC;
    				Output[number_for_output++]=0;
    				return 0;
    			}
    		else
    			return 1;
    	}

    Человек писал компилятор. Самые эпичные моменты

    epichniygovnokoder, 31 Января 2015

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

    +126

    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
    class Program
        {
            static void Main(string[] args)
            {
                User admin = new User() { Name = "Admin", Dick = new User.UserDick(18) };
                User guest = new User() { Name = "guest", Dick = new User.UserDick(12) };
                Console.WriteLine(guest.Suck(admin.Dick));
                Console.ReadLine();
            }
        }
    
        public class User
        {
            public User() { }
            public class UserDick
            {
                public UserDick(int _length) { Length = _length; }
                public long Length { get; set; }
            }
            public string Name { get; set; }
            public UserDick Dick { get; set; }
    
            public string Suck(UserDick _dick)
            {
                return String.Format("{0}: OH YEAH FUCK ME BY YOUR {1} CM YEEEEEAH I WANNA SUCK YOUR {2} DICK!", Name, _dick.Length, _dick.Length >= 17 ? "BIG" : "SMALL");
            }
        }

    DesmondHume, 17 Января 2015

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