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

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

    +100

    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
    function Encrypt(jstr: String): String;
    var
      I: Integer;
      A: Real;
    begin
      if Length(jstr) = 0 Then begin
        Result := '';
        Exit;
      end;
      A := 0;
        for I := 0 To Length(jstr) do
          A := A + (Ord(jstr[I]) * Pos(jstr[I],jstr)) / 33;
      Result := FormatFloat('0000000000.0000000000',A);
      if Pos(',',Result) > 0 then begin
        Insert('.',Result,Pos(',',Result));
        Delete(Result,Pos(',',Result),1);
      end;
    end;

    bugmenot, 17 Ноября 2011

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

    +100

    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
    {Podschet dlini}
    Reset(f1);
    kol:=0;
    while not eof(f1) do begin
    readln(f1,l);
    For i1:=1 to length(l) do if (l[i]='a')or(l[i]='A') or (l[i]='b')or(l[i]='B')
    or(l[i]='c')or(l[i]='C')or(l[i]=' ')or(l[i]='d')or(l[i]='D')
    or(l[i]='e')or (l[i]='E') or(l[i]='f') or(l[i]='F')
    or (l[i]='g')or (l[i]='G') or (l[i]='h')or(l[i]='H')
    or(l[i]='i')or(l[i]='I')or(l[i]='J')or(l[i]='j')
    or(l[i]='k')or(l[i]='K')or(l[i]='l')or(l[i]='L')
    or (l[i]='m')or (l[i]='M')or(l[i]='n')or(l[i]='N')
    or (l[i]='o')or(l[i]='O')or(l[i]='p')or(l[i]='P')
    or(l[i]='q')or(l[i]='Q')or (l[i]='r')or (l[i]='R')
    or(l[i]='S')or(l[i]='s')or(l[i]='t')or(l[i]='T')
    or(l[i]='v')or(l[i]='V') or(l[i]='w')or(l[i]='W')
    or(l[i]='u')or(l[i]='U')or(l[i]='x')or(l[i]='X')
    or(l[i]='y')or(l[i]='Y')or (l[i]='z')or(l[i]='Z') then
    kol:=kol+1;
    end;
    WriteLn('kol=',kol);

    Необходимо создать текстовый файл, содержащий исходную программу, а также подсчитать длину созданного файла.
    http://ithappens.ru/story/7652

    d_dev, 31 Октября 2011

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

    +100

    1. 1
    2. 2
    3. 3
    4. 4
    case
       0: FilterList.Add('RCHECK = '+''''+'+'+'''');
       1: FilterList.Add('RCHECK = '+''''+'-'+'''');
    ...

    Автор кода жжот. Код реально работает. Но прочитать такое даже автор по прошествии года не сможет.

    Можно было проще
    0:FilterList.Add('RCHECK = ''+''');

    siqel, 25 Августа 2011

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

    +100

    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.Button1Click(Sender: TObject);
    Const
      NormText : string = 'АБВГДЕЁЖЗЫИЙКЛМНОПРСТУФХЦЧШЩЬЪЭЮЯ ';
      ObeznogText : string = 'А6ВrДЕЁЖ3ЫNµКЛМН0ПРС†YФXЦ4ШЩЬЪЗЮR ';
    Var
      sText, sBeznogText : String;
      i : Integer;
    BEGIN
     sText := Memo1.Text;
     sText := AnsiUpperCase(sText);
     sBeznogText := '';
     For i := 1 to Length(sText) do
      Begin
       sBeznogText := sBeznogText + (Copy(ObeznogText, Pos(sText[i], NormText), 1));
       If sText[i] = ' ' then
        bEgin
         Randomize;
         Case Random(5) of
          1: begin
              sBeznogText := sBeznogText + 'ДОСМОТ? ';
             End;
          3: begin
              sBeznogText := sBeznogText + 'РYКN ';
             end;
          5: begin
              sBeznogText := sBeznogText + 'БЕЗНОГ? ';
             end;
         End;
        eNd;
      End;
     Memo1.Text := sBeznogText;
    END;

    Автоматическое обезноживание текста. Сплойлер: БЕ3НОГNМ

    Govnocoder#0xFF, 03 Апреля 2011

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

    +100

    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
    dats:=datetostr(DateTimePicker1.Date);
    datp:=datetostr(DateTimePicker2.Date);
    datsc:=copy(dats,1,2);
    datsm:=copy(dats,4,2);
    datsg:=copy(dats,7,4);
    datpc:=copy(datp,1,2);
    datpm:=copy(datp,4,2);
    datpg:=copy(datp,7,4);
    idatsc:=strtoint(datsc);
    idatsm:=strtoint(datsm);
    idatsg:=strtoint(datsg);
    idatpc:=strtoint(datpc);
    idatpm:=strtoint(datpm);
    idatpg:=strtoint(datpg);
    tdatc:=strtoint(copy(p[i,6],1,2));
    tdatm:=strtoint(copy(p[i,6],4,2));
    tdatg:=strtoint(copy(p[i,6],7,4)); 
    if not ((idatsg>tdatg) or ((idatsg=tdatg) and (idatsm>tdatm)) or ((idatsc>tdatc) and (idatsm>=tdatm)) or (idatpg<tdatg) or ((idatpg=tdatg) and (idatpm<tdatm)) or ((idatpc<tdatc) and (idatpm<=tdatm))) then

    Проверка или дата с массива включена в диапазон дат с DateTimePicker'ов (еще и с ошибкой в условии)
    И вся эта фигня в цикле... Как это увидел, валерьянкой отпаивали меня долго

    Nikitiy_II, 04 Января 2011

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

    +100

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    {Pascal}
    function f( a: boolean ) : boolean;
    begin
    if a then return := f(a) else return := false;
    end;

    При а - истина программа вылетит с переполненным стеком.

    Govnocoder#0xFF, 16 Ноября 2010

    Комментарии (32)
  8. Си / Говнокод #3816

    +100

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    f = fopen(file_name, "w");
    if (!f) {
      f = fopen(file_name, "w+");
      if (!f)
        logprintfl(EUCAWARN, "Cannot create %s!\n", file_name);
      else {
        len = fileno(f);
        if (len > 0)
          fchmod(len, S_IRUSR|S_IWUSR);
      }
    }

    Суровые калифорнийские парни сурово создают суровые файлы...

    raorn, 29 Июля 2010

    Комментарии (2)
  9. Pascal / Говнокод #3373

    +100

    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
    procedure WriteCharXY(_bx,by:integer; ch:char; tcol:word);
    var buf:array[1..18,1..12] of word;
    XOfs:longint;
    x,y,px,py:integer;
    begin
    XOfs:=GetCharOffset(ch);
    if xofs=0 then fillchar(buf,sizeof(buf),200) else
    fromXMS(XOfs,addr(buf),432);
    for y:=1 to 18 do
    for x:=1 to 12 do begin
    if buf[y,x]=0 then begin
       px:=_bx+x; py:=by+y;
       asm
       mov   bx,px;  add   bx,actviewport.x1;  cmp   bx,fillviewport.x1;
       jl    @end;  cmp   bx,fillviewport.x2; jg    @end;
       mov   cx,currentmode.scanline;  cmp   bx,cx;  jnb   @end;
       mov   ax,py;  add   ax,actviewport.y1;  cmp   ax,fillviewport.y1;
       jl    @end;  cmp   ax,fillviewport.y2;  jg    @end;
       add   ax,pageadd;  mul   cx;  add   bx,bx;
       add   ax,bx;  adc   dx,0;  mov   si,ax;
       cmp   dx,lastbank;  je    @next;  push  dx;
       call  nearsetbank2;  @next:  mov   es,[currentmode.writeptr];
       mov   ax,tcol;  {cmp   writemode,0;  jne   @doxor;}
       mov   es:[si],ax;  {jmp   @end;  @doxor: xor   es:[si],ax;}  @end:
       end;
    end;
    end;
    end;
    
    procedure WriteStringXY(x,y,maxx:integer; s:string; col:word);
    var tx,ty:integer; i:word;
    begin tx:=x; ty:=y;
    for i:=0 to length(s) do begin
    writecharXY(tx,ty,s[i],col);
    inc(tx,GetCharWidth(s[i]));
    if (tx>=maxx) and (s[i]=' ') then begin inc(ty,18); tx:=x; end;
    end;
    end;
    
    procedure Write5Strings(x,y,maxx:integer; col:word; s1,s2,s3,s4,s5:string;
    letterdelay:byte);
    var tx,ty:integer; t,i:word;
    st:array[1..5] of string;
    begin tx:=x; ty:=y;
    st[1]:=s1; st[2]:=s2; st[3]:=s3; st[4]:=s4; st[5]:=s5;
    for t:=1 to 5 do begin
    if length(st[t])=0 then exit;
       for i:=1 to length(st[t]) do begin
       writecharXY(tx,ty,st[t][i],col);
       if letterdelay>0 then pdel(letterdelay);
       inc(tx,GetCharWidth(st[t][i]));
       if (tx>=maxx-100) and (st[t][i]=' ') then begin
       inc(ty,18); tx:=x; end;
       end;
    end;
    end;

    Молодость.

    runewalsh, 01 Июня 2010

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

    +100

    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
    int wmain()
    {
                    _rmCfg rmCfg;
                    double tt;
                    int i;
    
                            String *filePath=S"C:\\rm\\rm.cfg";
                            String * sqlstr;
                            rmCfg.isread=0;
                            String * dir[];
                            DateTime dt;
                            if (File::Exists(filePath))
                            {
                                    StreamReader *sr= new StreamReader(filePath);
                                    rmCfg.gosanPath=sr->ReadLine();
                                    rmCfg.iakServer=sr->ReadLine();
                                    rmCfg.iakUser=sr->ReadLine();
                                    rmCfg.iakPassword=sr->ReadLine();
                                    rmCfg.trackId=sr->ReadLine()->ToInt32(0);
                            //      rmCfg.trName=sr->ReadLine();
    
                                    Console::WriteLine(S"Viewing directory: ");
                                    Console::Write(rmCfg.gosanPath);
                                    Console::WriteLine();

    Писано было на втором фреймворке. Так бы и продолжал писать, если бы товарищ не намекнул про сериализацию.

    ursus, 05 Мая 2010

    Комментарии (20)
  11. Си / Говнокод #2526

    +100

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    #include <iostream>
    int main(void)
    {
      for (int i=0;i<600000000;i++)
      cout<<"Ten minuters";
    //IT Works!
    }

    Реальный код с cyberforum. Задание звучало как "Написать таймер, каждые 10 минут выводящий какое-нибудь сообщение". Один умник написал такое нечто, от чего я просто впал в ступор.

    darkcheg, 02 Февраля 2010

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