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

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

    +103

    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
    glpushmatrix;
    if ((commandflat=2)and((commandaxis=2) or(commandaxis=3)))or((commandflat=1)and(commandaxis=1)) then
     glrotatef(faza,rotation[0],rotation[1],rotation[2]);
    
      glcolor3f(kubcol[Y[2,1,1]].R,kubcol[Y[2,1,1]].G,kubcol[Y[2,1,1]].B);
     glbegin(gl_quads);
      glvertex3f(-1.5,1.5,1.5);
      glvertex3f(-1.5,1.5,0.5);
      glvertex3f(-0.5,1.5,0.5);
      glvertex3f(-0.5,1.5,1.5);
     glend;
     glcolor3f(kubcol[X[1,1,1]].R,kubcol[X[1,1,1]].G,kubcol[X[1,1,1]].B);
     glbegin(gl_quads);
      glvertex3f(-1.5,1.5,1.5);
      glvertex3f(-1.5,1.5,0.5);
      glvertex3f(-1.5,0.5,0.5);
      glvertex3f(-1.5,0.5,1.5);
     glend;
     glcolor3f(kubcol[Z[2,1,1]].R,kubcol[Z[2,1,1]].G,kubcol[Z[2,1,1]].B);
     glbegin(gl_quads);
      glvertex3f(-1.5,1.5,1.5);
      glvertex3f(-0.5,1.5,1.5);
      glvertex3f(-0.5,0.5,1.5);
      glvertex3f(-1.5,0.5,1.5);
     glend;
     glcolor3f(0.5,0.5,0.5);
     glbegin(gl_quads);
      glvertex3f(-1.5,0.5,1.5);
      glvertex3f(-1.5,0.5,0.5);
      glvertex3f(-0.5,0.5,0.5);
      glvertex3f(-0.5,0.5,1.5);
     glend;
     glcolor3f(0.5,0.5,0.5);
     glbegin(gl_quads);
      glvertex3f(-0.5,1.5,1.5);
      glvertex3f(-0.5,1.5,0.5);
      glvertex3f(-0.5,0.5,0.5);
      glvertex3f(-0.5,0.5,1.5);
     glend;
     glcolor3f(0.5,0.5,0.5);
     glbegin(gl_quads);
      glvertex3f(-1.5,1.5,0.5);
      glvertex3f(-0.5,1.5,0.5);
      glvertex3f(-0.5,0.5,0.5);
      glvertex3f(-1.5,0.5,0.5);
     glend;
    glpopmatrix;
    ///////112

    Захотел как то кубик рубика накодить, это фрагмент модуля из 1214 строк который выводит 26 кубиков. Цвет лицевых граней берется из массива, остальные - серые.

    Dent, 14 Февраля 2011

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

    +103

    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
    Const MAX32 : DWord = $FFFFFFFF;
     
    Var
        State : Array[0..15] of DWord;
        Count : Array[0..1] of DWord;
        Len : Byte;
        Buffer : Array[0..31] of Byte;
     
    Procedure SHIFT12(var U : Array of DWord; var M : Array of DWord; var S : Array of DWord);
    Begin
            U[0] := M[0] xor S[6];
            U[1] := M[1] xor S[7];
            U[2] := M[2] xor (S[0] shl 16) xor (S[0] shr 16) xor (S[0] and $FFFF) xor
                    (S[1] and $FFFF) xor (S[1] shr 16) xor (S[2] shl 16) xor S[6] xor (S[6] shl 16) xor
                    (S[7] and $FFFF0000) xor (S[7] shr 16);
            U[3] := M[3] xor (S[0] and $FFFF) xor (S[0] shl 16) xor (S[1] and $FFFF) xor
                    (S[1] shl 16) xor (S[1] shr 16) xor (S[2] shl 16) xor (S[2] shr 16) xor
                    (S[3] shl 16) xor S[6] xor (S[6] shl 16) xor (S[6] shr 16) xor (S[7] and $FFFF) xor
                    (S[7] shl 16) xor (S[7] shr 16);
            U[4] := M[4] xor
                    (S[0] and $FFFF0000) xor (S[0] shl 16) xor (S[0] shr 16) xor
                    (S[1] and $FFFF0000) xor (S[1] shr 16) xor (S[2] shl 16) xor (S[2] shr 16) xor
                    (S[3] shl 16) xor (S[3] shr 16) xor (S[4] shl 16) xor (S[6] shl 16) xor
                    (S[6] shr 16) xor(S[7] and $FFFF) xor (S[7] shl 16) xor (S[7] shr 16);
            U[5] := M[5] xor (S[0] shl 16) xor (S[0] shr 16) xor (S[0] and $FFFF0000) xor
                    (S[1] and $FFFF) xor S[2] xor (S[2] shr 16) xor (S[3] shl 16) xor (S[3] shr 16) xor
                    (S[4] shl 16) xor (S[4] shr 16) xor (S[5] shl 16) xor  (S[6] shl 16) xor
                    (S[6] shr 16) xor (S[7] and $FFFF0000) xor (S[7] shl 16) xor (S[7] shr 16);
            U[6] := M[6] xor S[0] xor (S[1] shr 16) xor (S[2] shl 16) xor S[3] xor (S[3] shr 16) xor
                    (S[4] shl 16) xor (S[4] shr 16) xor (S[5] shl 16) xor (S[5] shr 16) xor S[6] xor
                    (S[6] shl 16) xor (S[6] shr 16) xor (S[7] shl 16);
            U[7] := M[7] xor (S[0] and $FFFF0000) xor (S[0] shl 16) xor (S[1] and $FFFF) xor
                    (S[1] shl 16) xor (S[2] shr 16) xor (S[3] shl 16) xor S[4] xor (S[4] shr 16) xor
                    (S[5] shl 16) xor (S[5] shr 16) xor (S[6] shr 16) xor (S[7] and $FFFF) xor
                    (S[7] shl 16) xor (S[7] shr 16);
    End;
     
    Procedure SHIFT16(var H : Array of DWord; var V : Array of DWord; var U : Array of DWord);
    Begin
            V[0] := H[0] xor (U[1] shl 16) xor (U[0] shr 16);
            V[1] := H[1] xor (U[2] shl 16) xor (U[1] shr 16);
            V[2] := H[2] xor (U[3] shl 16) xor (U[2] shr 16);
            V[3] := H[3] xor (U[4] shl 16) xor (U[3] shr 16);
            V[4] := H[4] xor (U[5] shl 16) xor (U[4] shr 16);
            V[5] := H[5] xor (U[6] shl 16) xor (U[5] shr 16);
            V[6] := H[6] xor (U[7] shl 16) xor (U[6] shr 16);
            V[7] := H[7] xor (U[0] and $FFFF0000) xor (U[0] shl 16) xor (U[7] shr 16) xor
                    (U[1] and $FFFF0000) xor (U[1] shl 16) xor (U[6] shl 16) xor (U[7] and $FFFF0000);
    End;

    qbasic, 31 Января 2011

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

    +103

    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
    /// <summary>
        /// Абстрактный класс, который содержит в себе информацию о человеке
        /// </summary>
        public abstract class APerson
        {
            protected string name;
            protected DateTime birthTime;
            protected ESex sex; // защищенный секс такой защищенный:) 
             
            //реализация
            //..
            //реализация 
        }
    
        /// <summary>
        /// Перечисление ESex - содержит пол человека
        /// </summary>
        public enum ESex
        {
            Мужской,
            Женский
        }

    В процессе написания курсовой. Да-да, студентота.

    tooZ, 13 Декабря 2010

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

    +103

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    if Column.Field.AsInteger > 10 then
    DrawGridCheckBox(DBGrid1.Canvas, Rect, true)
    else
    DrawGridCheckBox(DBGrid1.Canvas, Rect, false)
    end;

    Классика жанра

    gorsash, 10 Ноября 2010

    Комментарии (6)
  6. PHP / Говнокод #3595

    +103

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    fputs(fopen("ttext.txt", "w+"),"Мега текст!"); # создание файла и запись
    fpassthru(fopen("ttext.txt", "w+")); # отображение
    copy("ttext.txt", "ttext2.txt"); # копирование
    fputs(fopen("ttext2.txt", "w+"), "скопированный Мега текст"); # запись
    rename("ttext2.txt", "dctext.txt"); # переименование
    fpassthru(fopen("dctext.txt", "w+")); # отображение
    unlink("dctext.txt"); # удаление
    fclose(fopen("ttext.txt", "w+")); # закрытие

    Vasiliy, 29 Июня 2010

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

    +103

    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
    program lab15;
     uses crt;
     const nmax=100;
     var z,i,j,k,n,m:integer;
         pr:boolean;
         stolb:boolean;
     sum:array[1..nmax] of integer;
     A:array[1..nmax,1..nmax] of integer;
    
     procedure swap(var a,b:integer);
     var c:integer;
     begin
     c:=0;
     c:=a;
     a:=b;
     b:=c;
     end;
    
     function prostoe(x:integer):boolean;
     var i:integer;
         p:boolean;
         begin
     x:=abs(x);
     p:=false;
     if x>1 then p:=true;
     for i:=2 to x-1 do
     if x mod i=0 then p:=false;
     prostoe:=p
     end;
    
    
     begin
     z:=0;
     stolb:=false;
     pr:=false;
       clrscr;
        write('n= ');
        readln(n);
        write('m= ');
        readln(m);
        for i:=1 to n do
          for j:=1 to m do
            read(A[i,j]);
        for i:=1 to n do
        sum[i]:=0;
        for i:=1 to n do
         for j:=1 to m do
           sum[i]:=sum[i]+abs(a[i,j]);
             for i:=1 to n do
              for j:=1 to m do
               if prostoe(a[i,j])=true then pr:=true;
    
             for i:=1 to m-1 do
             begin
               for j:=i+1 to m do
               begin
               z:=0;
                for k:=1 to n do
                 begin
                   if a[k,i]=a[k,j] then z:=z+1;
                   if z=n then stolb:=true;
                 end;
               end;
             end;
    
                if (pr=true) and (stolb=true) then
                begin
                   for i:=1 to n-1 do
                   for j:=i+1 to n  do
                     if sum[i]>sum[j] then begin
                     swap(sum[i],sum[j]);
                     for k:=1 to m do
                       swap(a[i,k],a[j,k]);
                     end;
                end;
    
      writeln('stolbec= ', stolb);
      writeln('prostoe= ', pr);
    
      for i:=1 to n do
      begin
      writeln;
      for j:=1 to m do
      write(a[i,j], ' ');
      end;
        readkey;
        end.

    basic, 14 Июня 2010

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

    +103

    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
    procedure TForm1.UpDown2Click(Sender: TObject; Button: TUDBtnType);
    begin
    If (UpDown2.Position = 0) or (UpDown2.Position = 5) or (UpDown2.Position = 6) or
       (UpDown2.Position = 7) or (UpDown2.Position = 8) or (UpDown2.Position = 9) or
       (UpDown2.Position = 10) or (UpDown2.Position = 11) or (UpDown2.Position = 12) or
       (UpDown2.Position = 13) or (UpDown2.Position = 14) or (UpDown2.Position = 15) or
       (UpDown2.Position = 16) or (UpDown2.Position = 17) or (UpDown2.Position = 18) or
       (UpDown2.Position = 19) or (UpDown2.Position = 20) or (UpDown2.Position = 25) or
       (UpDown2.Position = 26) or (UpDown2.Position = 27) or (UpDown2.Position = 28) or
       (UpDown2.Position = 29) or (UpDown2.Position = 30) or (UpDown2.Position = 35) or
       (UpDown2.Position = 36) or (UpDown2.Position = 37) or (UpDown2.Position = 38) or
       (UpDown2.Position = 39) or (UpDown2.Position = 40) or (UpDown2.Position = 45) or
       (UpDown2.Position = 46) or (UpDown2.Position = 47) or (UpDown2.Position = 48) or
       (UpDown2.Position = 49) or (UpDown2.Position = 50) or (UpDown2.Position = 55) or
       (UpDown2.Position = 56) or (UpDown2.Position = 57) or (UpDown2.Position = 58) or
       (UpDown2.Position = 59) or (UpDown2.Position = 60)
        then StaticText4.Caption := 'минут';
    
    If (UpDown2.Position = 1) or (UpDown2.Position = 21) or (UpDown2.Position = 31) or
       (UpDown2.Position = 41) or (UpDown2.Position = 51)
    then StaticText4.Caption := 'минуту';
    
    If (UpDown2.Position = 2) or (UpDown2.Position = 22) or (UpDown2.Position = 23) or
       (UpDown2.Position = 24) or (UpDown2.Position = 32) or (UpDown2.Position = 33) or
       (UpDown2.Position = 34) or (UpDown2.Position = 42) or (UpDown2.Position = 43) or
       (UpDown2.Position = 44) or (UpDown2.Position = 52) or (UpDown2.Position = 53) or
       (UpDown2.Position = 54)
    then StaticText4.Caption := 'минуты';
    
    If UpDown2.Position>60 then ShowMessage('больше нельзя');
    
    end;

    Дао создания таймера обратного отсчета.
    Канон второй: вычисление плюральных окончаний.
    Комментарии и форматирование авторские.

    bugmenot, 08 Июня 2010

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

    +103

    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
    /*    Copyright 2009 10gen Inc.
     *
     *    Licensed under the Apache License, Version 2.0 (the "License");
     *    you may not use this file except in compliance with the License.
     *    You may obtain a copy of the License at
     *
     *    http://www.apache.org/licenses/LICENSE-2.0
     *
     *    Unless required by applicable law or agreed to in writing, software
     *    distributed under the License is distributed on an "AS IS" BASIS,
     *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     *    See the License for the specific language governing permissions and
     *    limitations under the License.
     */
    
    /* all the numbers that fit in a 4 byte string */
    const char bson_numstrs[1000][4] = {
        "0",  "1",  "2",  "3",  "4",  "5",  "6",  "7",  "8",  "9",
        "10", "11", "12", "13", "14", "15", "16", "17", "18", "19",
    	/* 105 строк поскипано */
        "980", "981", "982", "983", "984", "985", "986", "987", "988", "989",
        "990", "991", "992", "993", "994", "995", "996", "997", "998", "999",
    };

    Взято отсюда - http://github.com/mongodb/mongo-c-driver/blob/master/src/numbers.c . А это коммит - http://github.com/mongodb/mongo-c-driver/commit/0198225180a51e0b0b8a84f25b34b3047d3b9c80

    raorn, 02 Июня 2010

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

    +103

    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
    var
      resStream: TResourceStream;
      memStream: TMemoryStream;
      DLL: THandle;
      tempFile: string;
    
      excel: variant;
      wbook: OLEVariant;
    begin
      if not IsOLEObjectInstalled('Excel.Application') then
        begin
          MessageBox(Handle, PChar('Для открытия фаблонов форм необходимо установить'+#13+
                                   'Microsoft Excel'), 'Ошибка загрузки формы.', MB_ICONINFORMATION);
          exit
        end;
      tempFile := extractFilePath(paramStr(0))+'DATA\PLUGINS\$temp$.xxx';
      if ListView1.Selected = nil then exit;
      if not FileExists(ListView1.Selected.SubItems.Strings[2]) then exit;
      DLL := loadLibrary(PChar(ListView1.Selected.SubItems.Strings[2]));
      if DLL = INVALID_HANDLE_VALUE then begin
                                           freeLibrary(DLL);
                                           exit
                                         end;
      resStream := TResourceStream.Create(DLL, 'FORMA', MakeIntResource(10));
      memStream := TMemoryStream.Create;
      memStream.LoadFromStream(resStream);
      if fileExists(tempFile) then deleteFile(tempFile);
      memStream.SaveToFile(tempFile);
      setFileAttributes(PChar(tempFile), FILE_ATTRIBUTE_HIDDEN or
                                         FILE_ATTRIBUTE_TEMPORARY);
      memStream.Free;
      resStream.Free;
      freeLibrary(DLL);
    
      excel := createOLEObject('Excel.Application');
      excel.Visible := TRUE;
      wbook := excel.Workbooks.Open(tempFile)
    end;

    когда-то кому-то в дипломнике вот такое написал. с понтом - подключаем плагины и они в эксель выводят программно новые виды форм. хотя экселевский файл тупо вкомпилен в ресурс библиотеки

    ganja_boy, 24 Мая 2010

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

    +103

    1. 1
    2. 2
    3. 3
    4. 4
    private ListBoxItem FindItem(string guid)
    {
            return _userlist.Items.Cast<ListBoxItem>().FirstOrDefault(item => ((TextBlock) ((StackPanel) item.Content).Children[1]).Text == guid);
    }

    Функция поиска элемента в ListBox по значению Guid в одну строку. Наговнокодил ReSharper.

    botinko, 09 Мая 2010

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