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

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

    +98

    1. 1
    enum { SIZEOF_INT_AS_STR = sizeof("4294967295,")-1 };

    Что это? :-O

    anmartex, 06 Апреля 2012

    Комментарии (37)
  3. Pascal / Говнокод #8903

    +98

    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
    if RadioGroup1.ItemIndex=0   then cpr:=cpr+1;
    if RadioGroup1.ItemIndex=1   then cth:=cth+1;
    if RadioGroup2.ItemIndex=0   then cch:=cch+1;
    if RadioGroup2.ItemIndex=1  then czs:=czs+1;
    if RadioGroup3.ItemIndex=0   then chd:=chd+1;
    if RadioGroup3.ItemIndex=1  then cpr:=cpr+1;
    if RadioGroup4.ItemIndex=0   then  cth:=cth+1;
    if RadioGroup4.ItemIndex=1  then cch:=cch+1;
    if RadioGroup5.ItemIndex=0   then czs:=czs+1;
    if RadioGroup5.ItemIndex=1  then chd:=chd+1;
    if RadioGroup6.ItemIndex=0   then cpr:=cpr+1;
    if RadioGroup6.ItemIndex=1  then cch:=cch+1;
    if RadioGroup7.ItemIndex=0   then chd:=chd+1;
    if RadioGroup7.ItemIndex=1  then cth:=cth+1;
    ....// Это всё в 60 строк
    if (cpr>cth) and (cpr>cch) and (cpr>czs) and (cpr>chd) then cpr1:=+1
    else
    if (cth>cpr) and (cth>cch) and (cth>czs) and (cth>chd) then cth1:=+1
    else
    if (cch>cpr) and (cch>cth) and (cch>czs) and (cch>chd) then cch1:=+1
    else
    if (czs>cpr) and (czs>cch) and (czs>cth) and (czs>chd) then czs1:=+1
    else
    if (chd>cpr) and (chd>cch) and (chd>czs) and (chd>cth) then chd1:=+1;
    
    if cpr>chd or czs or cth or cch     then
    begin
    ShowMessage('человек-природа – все профессии, связанные с растениеводством, животноводством и лесным хозяйством;')   ;
    Datamodule4.ADOTable1.Edit;
    Datamodule4.ADOTable1.FieldValues['test2']:=('человек-природа – все профессии, связанные с растениеводством, животноводством и лесным хозяйством;');
    Datamodule4.ADOTable1.Post;
    end
    else
    if chd>cpr or cth or cch or czs   then   begin
    ShowMessage('человек-техника – все технические профессии;')   ;
    Datamodule4.ADOTable1.Edit;
    Datamodule4.ADOTable1.FieldValues['test2']:=('человек-техника – все технические профессии;');
    Datamodule4.ADOTable1.Post;
    ...... И далее результаты в общем их 5
    отдельная кнопка для вывода остальных 10 вопросов х)
    procedure TForm1.Button1Click(Sender: TObject);
    begin
    Radiogroup11.Visible:=true;
    Radiogroup12.Visible:=true;
    Radiogroup13.Visible:=true;
    Radiogroup14.Visible:=true;
    Radiogroup15.Visible:=true;
    Radiogroup16.Visible:=true;
    Radiogroup17.Visible:=true;
    Radiogroup18.Visible:=true;
    Radiogroup19.Visible:=true;
    Radiogroup20.Visible:=true;
    Button2.Visible:=True;
    end;

    Программа тестирования на профориентацию
    хД сколько он radiogroup создал)

    Ryuko, 05 Января 2012

    Комментарии (8)
  4. Pascal / Говнокод #7838

    +98

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    for j:=k+1 to n+1 do
    	begin
    	r:=a[j,k]/a[k,k];
    	for i:=k to n do
                    begin
                    a[j,i]:=power(((a[j,i]-r*a[k,i]):a[i,j]),a[j,i]);
                    end;

    К сожалению, я уже забыл, какой идентификатор что значит :(
    Придется переписывать.

    Lioncure, 12 Сентября 2011

    Комментарии (23)
  5. Pascal / Говнокод #7423

    +98

    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
    case ColorChunkStart of  
       0 : result := RGB(255,   
                         (255 div ColorChunk) * ColorChunkIndex,   
                         0);   
       1 : result := RGB(255 - (255 div ColorChunk) * ColorChunkIndex,   
                         255,   
                         0);   
       2 : result := RGB(0, 255, (255 div ColorChunk) * ColorChunkIndex);   
       3 : result := RGB(0,   
                         255 - (255 div ColorChunk) * ColorChunkIndex,   
                         255);   
       4 : result := RGB((255 div ColorChunk) * ColorChunkIndex,   
                         0,   
                         255);   
       5 : result := RGB(255,   
                         0,   
                         255 - (255 div ColorChunk) * ColorChunkIndex);   
      else  
        if WrapToRed <> false then  
          result := RGB(255, 0, 0) else  
          result := RGB(255, 0, 255);   
    end;{Case}

    Говно?

    Fai, 02 Августа 2011

    Комментарии (23)
  6. Pascal / Говнокод #7178

    +98

    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
    function Prime (N: longword): boolean;
    var
    	i : longword;
    	Max : single;
    begin
    	if N = 2
    		then Prime := true
    	else if (N <= 1) or (N mod 2 = 0)
    		then Prime := false
    	else begin
    		Prime := true;
    		i := 3; Max := sqrt(N);
    		while i <= Max do begin
    			if N mod i = 0 then begin
    				Prime := false; 
    				exit
    			end;
    			i := i + 2
    		end
    	end
    end;
    
    var
    	a, i : longword;
    
    begin
    	read(a);
    	for i := 2 to a do
    		if Prime(i)
    			then writeln(i, ' is a prime number');
    end.

    Нахождение простых чисел.

    sunshinelf, 06 Июля 2011

    Комментарии (29)
  7. Pascal / Говнокод #5846

    +98

    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
    Procedure TreeNodeBuilding(Tree: TTreeView; Query: TZQuery; DestinationNode: TTreeNode;
                              IdColumn, NameColumn, FilterColumn, TableType: String; Filtering:Boolean; ImageIndex:Integer);
      //-------------------------------------------------//
      Function AddOrNot:Boolean; //Фильтрация по ИД
      var
        Add: Boolean;
      begin
      Add:=False;
      If Filtering=False then Add:=True else
        begin
        if DestinationNode=nil then Add:=True else
          begin
          MyNodeParamPtr:=DestinationNode.Data;
          if MyNodeParamPtr^.id=Query.FieldValues[FilterColumn] then Add:=True;
          end;
        end;
      Result:=Add;
      end;
      //-------------------------------------------------//
      Procedure AddTreeNodeToViewer; //Добавление ветки
      var
        MyNode: TTreeNode;
      begin
      //Добавляем новую запись в массив и заполняем её
    //  Inc(ArrMyNodeParamLength);
    //  SetLength(ArrMyNodeParam, ArrMyNodeParamLength);
      New(MyNodeParamPtr);
      MyNodeParamPtr^.id:=Query.FieldValues[IdColumn];
      MyNodeParamPtr^.table:=TableType;
      //Добавляем новый узел дерева и указатель на соотв запись
      if DestinationNode=nil then
      MyNode:=Tree.Items.AddObject(DestinationNode, VarToStr(Query.FieldValues[NameColumn]), MyNodeParamPtr)
        else MyNode:=Tree.Items.AddChildObject(DestinationNode, VarToStr(Query.FieldValues[NameColumn]), MyNodeParamPtr);
      MyNode.ImageIndex:=ImageIndex;
      MyNode.SelectedIndex:=ImageIndex;
      end;
      //-------------------------------------------------//
    begin
    //
    Query.First;
    if AddOrNot=True then AddTreeNodeToViewer;
    Query.Next;
    while not Query.Eof do
      begin
      if AddOrNot=True then AddTreeNodeToViewer;
      Query.Next;
      end;
    end;

    Добавление ветки в TreeView. Я тут явно перемудрил

    nikitasnv, 02 Марта 2011

    Комментарии (5)
  8. Pascal / Говнокод #5208

    +98

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    if a[512] < x then L := n – 512 + 1;
    if a[L + 256] < x then L := L + 256;
    if a[L + 128] < x then L := L + 128;
    if a[L + 64] < x then L := L + 64;
    if a[L + 32] < x then L := L + 32;
    if a[L + 16] < x then L := L + 16;
    if a[L + 8] < x then L := L + 8;
    if a[L + 4] < x then L := L + 4;
    if a[L + 2] < x then L := L + 2;
    if a[L + 1] < x then L := L + 1;

    Взято из методического пособия по программированию - отрывок из алгоритма бинарного поиска (реализация для сходимости в 9 шагов)

    diok, 10 Января 2011

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

    +98

    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
    //
    // Замена блоков __try/__finally нашей реализацией. Примеры использования:
    // NTSTATUS SomeFunc() {
    //     X *p = NULL;
    //     NTSTATUS status = STATUS_SUCCESS;
    //     Try {
    //         p = new(NonPagedPool) X;
    //         if (!p) Leave(status = STATUS_INSUFFICIENT_RESOURCES);
    //
    //         status = SomeKernelFunc();
    //         LeaveNS(status = STATUS_UNSUCCESSFUL);
    //     } Finally {
    //         if (p) delete p;
    //     }
    //     return status;
    // }
    //
    #define Try if (1)
    #define Finally try_exit: NOTHING
    #define Leave(s) { s; goto try_exit; }
    #define LeaveNS(s) {if (!NT_SUCCESS(status)) Leave(s);}
    #define Run(s) {status = s; LeaveNS(;);}

    Суровые исключения для Win32 драйвера

    rat4, 16 Сентября 2010

    Комментарии (7)
  10. Pascal / Говнокод #3864

    +98

    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
    procedure TfmAllParams.NInsertParamSelebrationClick(Sender: TObject);
    var
      str: string;
    begin
      str := //Новый год
        ' if not exists (select id from sta_param_selebration ' +
        '            where date_selebration=' + #39 + '01.01.' + IntToStr(YearOf(GetServerDate)) + #39 + ')' +
        ' insert into sta_param_selebration (selebration_day, selebration_month ,selebration_state,text_selebration,selebration_year)' +
        ' values(1,1,null,null,null) ' +
            //День св. Валентина
      ' if not exists (select id from sta_param_selebration ' +
        '            where date_selebration=' + #39 + '14.02.' + IntToStr(YearOf(GetServerDate)) + #39 + ')' +
        ' insert into sta_param_selebration (selebration_day, selebration_month ,selebration_state,text_selebration,selebration_year)' +
        ' values(14,2,null,null,null) ' +
            //8 марта
      ' if not exists (select id from sta_param_selebration ' +
        '            where date_selebration=' + #39 + '08.03.' + IntToStr(YearOf(GetServerDate)) + #39 + ')' +
        ' insert into sta_param_selebration (selebration_day, selebration_month ,selebration_state,text_selebration,selebration_year)' +
        ' values(8,3,' + #39 + 'жін.' + #39 + ',null,null) ' +
            //1 мая
      ' if not exists (select id from sta_param_selebration ' +
        '            where date_selebration=' + #39 + '01.05.' + IntToStr(YearOf(GetServerDate)) + #39 + ')' +
        ' insert into sta_param_selebration (selebration_day, selebration_month ,selebration_state,text_selebration,selebration_year)' +
        ' values(1,5,null,null,null) ' +
            //Пасха
      ' if not exists (select id from sta_param_selebration ' +
        '            where date_selebration=' + #39 + '04.04.2010' + #39 + ' and text_selebration=' + #39 + 'Pasha' + #39 + ')' +
        ' insert into sta_param_selebration (selebration_day, selebration_month ,text_selebration,selebration_year)' +
        ' values(4,4,' + #39 + 'Pasha' + #39 + ',2010) ' +
    
      ' if not exists (select id from sta_param_selebration ' +
        '            where date_selebration=' + #39 + '24.04.2011' + #39 + ' and text_selebration=' + #39 + 'Pasha' + #39 + ')' +
        ' insert into sta_param_selebration (selebration_day, selebration_month ,text_selebration,selebration_year)' +
        ' values(24,4,' + #39 + 'Pasha' + #39 + ',2011) ' +
    
       // И 10 таких же запросов на каждый год!
    
      ' if not exists (select id from sta_param_selebration ' +
        '            where date_selebration=' + #39 + '24.04.2022' + #39 + ' and text_selebration=' + #39 + 'Pasha' + #39 + ')' +
        ' insert into sta_param_selebration (selebration_day, selebration_month ,text_selebration,selebration_year)' +
        ' values(24,4,' + #39 + 'Pasha' + #39 + ',2022) ' +

    stokito, 03 Августа 2010

    Комментарии (3)
  11. Pascal / Говнокод #3446

    +98

    1. 001
    2. 002
    3. 003
    4. 004
    5. 005
    6. 006
    7. 007
    8. 008
    9. 009
    10. 010
    11. 011
    12. 012
    13. 013
    14. 014
    15. 015
    16. 016
    17. 017
    18. 018
    19. 019
    20. 020
    21. 021
    22. 022
    23. 023
    24. 024
    25. 025
    26. 026
    27. 027
    28. 028
    29. 029
    30. 030
    31. 031
    32. 032
    33. 033
    34. 034
    35. 035
    36. 036
    37. 037
    38. 038
    39. 039
    40. 040
    41. 041
    42. 042
    43. 043
    44. 044
    45. 045
    46. 046
    47. 047
    48. 048
    49. 049
    50. 050
    51. 051
    52. 052
    53. 053
    54. 054
    55. 055
    56. 056
    57. 057
    58. 058
    59. 059
    60. 060
    61. 061
    62. 062
    63. 063
    64. 064
    65. 065
    66. 066
    67. 067
    68. 068
    69. 069
    70. 070
    71. 071
    72. 072
    73. 073
    74. 074
    75. 075
    76. 076
    77. 077
    78. 078
    79. 079
    80. 080
    81. 081
    82. 082
    83. 083
    84. 084
    85. 085
    86. 086
    87. 087
    88. 088
    89. 089
    90. 090
    91. 091
    92. 092
    93. 093
    94. 094
    95. 095
    96. 096
    97. 097
    98. 098
    99. 099
    100. 100
    function TForm1.genpa(l: integer): string;
    const cifr_i_english: string =
    'ABCDEFGHIJKLMabcdefghijklm' +
    '0123456789' +
    'NOPQRSTUVWXYZnopqrstuvwxyz';
    const cifr: string =
    '1234567890';
    const rus:string =
    'йцукенгшщзхъфывапролджэячсмитьбю'+
    'ЙЦУКЕНГШЩЗХЪФЫВАПРОЛДЖЭЯЧСМИТЬБЮ';
    const cifr_i_rus: string =
    '1234567890'+
    'йцукенгшщзхъфывапролджэячсмитьбю'+
    'ЙЦУКЕНГШЩЗХЪФЫВАПРОЛДЖЭЯЧСМИТЬБЮ';
    const eng_i_rus: string =
    'йцукенгшщзхъфывапролджэячсмитьбю'+
    'ЙЦУКЕНГШЩЗХЪФЫВАПРОЛДЖЭЯЧСМИТЬБЮ'+
    'NOPQRSTUVWXYZnopqrstuvwxyz'+
    'ABCDEFGHIJKLMabcdefghijklm';
    const english: string =
    'NOPQRSTUVWXYZnopqrstuvwxyz'+
    'ABCDEFGHIJKLMabcdefghijklm';
    const en_ru_cifr :string =
    'NOPQRSTUVWXYZnopqrstuvwxyz'+
    'ABCDEFGHIJKLMabcdefghijklm'+
    'йцукенгшщзхъфывапролджэячсмитьбю'+
    'ЙЦУКЕНГШЩЗХЪФЫВАПРОЛДЖЭЯЧСМИТЬБЮ'+
    '1234567890';
    const spec :string =
    '!@#$%^&*()"№;:?/,\|=+-_}{][';
    const spec_ru :string =
    '!@#$%^&*()"№;:?/,\|=+-_}{]['+
    'йцукенгшщзхъфывапролджэячсмитьбю'+
    'ЙЦУКЕНГШЩЗХЪФЫВАПРОЛДЖЭЯЧСМИТЬБЮ';
    const eng_spec :string =
    'NOPQRSTUVWXYZnopqrstuvwxyz'+
    'ABCDEFGHIJKLMabcdefghijklm'+
    '!@#$%^&*()"№;:?/,\|=+-_}{][';
    const eng_ru_spec :string =
    'NOPQRSTUVWXYZnopqrstuvwxyz'+
    'ABCDEFGHIJKLMabcdefghijklm'+
    '!@#$%^&*()"№;:?/,\|=+-_}{]['+
    'йцукенгшщзхъфывапролджэячсмитьбю'+
    'ЙЦУКЕНГШЩЗХЪФЫВАПРОЛДЖЭЯЧСМИТЬБЮ';
    const cifr_spec :string =
    '1234567890'+
    '!@#$%^&*()"№;:?/,\|=+-_}{][';
    const cifr_en_spec :string =
    '1234567890'+
    '!@#$%^&*()"№;:?/,\|=+-_}{]['+
    'NOPQRSTUVWXYZnopqrstuvwxyz'+
    'ABCDEFGHIJKLMabcdefghijklm';
    const cifr_ru_en_spec :string =
    '1234567890'+
    '!@#$%^&*()"№;:?/,\|=+-_}{]['+
    'NOPQRSTUVWXYZnopqrstuvwxyz'+
    'ABCDEFGHIJKLMabcdefghijklm'+
    'йцукенгшщзхъфывапролджэячсмитьбю'+
    'ЙЦУКЕНГШЩЗХЪФЫВАПРОЛДЖЭЯЧСМИТЬБЮ';
    var
    x,y,engh:integer;
    str:string;
    d:integer;
    begin
       if CheckBox1.Checked =true then
       begin
       if CheckBox2.Checked =true then
       begin
       for d:=0 to l - 1  do
       begin
       engh:=Length(cifr_i_english);
       x:=RandomRange(1,engh);
       str:=str+cifr_i_english[x];
       end;
       result:=str;
       end;
       end;
       if CheckBox1.Checked =true then
       begin
       if CheckBox3.Checked =true then
       begin
       for d:=0 to l - 1  do
       begin
       engh:=Length(cifr_i_rus);
       x:=RandomRange(1,engh);
       str:=str+cifr_i_rus[x];
       end;
       result:=str;
       end;
       end;
       if CheckBox1.Checked =true then
       begin
       if CheckBox5.Checked =true then
       begin
       for d:=0 to l - 1  do
       begin
       engh:=Length(cifr_spec);
       x:=RandomRange(1,engh);
       str:=str+cifr_spec[x];
       end;

    МЯдаль мне ! Это говнокод говнокодов ! Супер генератор паролей !

    mistmax, 10 Июня 2010

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