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

    В номинации:
    За время:
  2. Куча / Говнокод #3689

    +89

    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
    ## dup_hq - merge ##
     dup     = opos!=pos || abs(dm)<2 || abs(dm)==3 ? 0 : dcn*5<dbc && dnn*5<dbc && 
    (dcn<1.25*thr || bn<bc && pos==lpos) || (dcn*dcn<dbc || dcn*5<dbc) && bn<bc && pos==lpos 
    && dnn<.9*dbc || dnn*9<dbc && dcn*3<dbc ? 1 : (dbc*dbc<dcn || dbc*5<dcn) && 
    bb<bc && pos==lpos && dbb<.9*dcn || dbb*9<dcn && dbc*3<dcn ||  dbb*5<dcn && 
    dbc*5<dcn &&  (dbc<1.25*thr || bb<bc && pos==lpos) ? -1 : 0
    mer = bom==false && opos==pos && dup==0 && abs(dm)>2 && 
          (dbc*8<dcn || dbc*8<dbb || dcn*8<dbc || dcn*8<dnn || dbc*2<thr ||
           dcn*2<thr || dnn*9<dbc && dcn*3<dbc || dbb*9<dcn && dbc*3<dcn)
    
    
    add  = bp1*cn2>bn2*cp1*(1+thr*.01) && bn0*cn2>bn2*cn0*(1+thr*.01) && 
              cn2*bn1>cn1*n2*(1+thr*.01)
    dup  = bom ? (bn0>bp2 && bn0>=bp1 && bn0>bn1 && bn0>bn2 && cn0<125 ? 
             (d12*d12<d10 || d12*9<d10) ? 1 :  (d10*d10<d12 || d10*9<d12) ? 
             0 : 4 : bp1>bp3 && bp1>=bp2 && bp1>bn0 && bp1>bn1 ? 1 : 0) : dup!=0 ? 
             dup : om>0 && om<5 ? (bbool==false ? 0 : om==4 && bp1*cn1<bn1*cp1 ||
             om==3 && d10<d01 || om==1 ? -1 : 1) : om==5 ? (bp1*cp2>bp2*cp1*(1+thr*.01) && 
             bn0*cp2>bp2*cn0*(1+thr*.01) && cp2*bn1>cn1*bp2*(1+thr*.01) &&
             (add==false || cp2*bn2>cn2*bp2) ? -2 : add ? 2 : bn0*cp1>bp1*cn0 && 
             (bn0*cn1<bn1*cn0 || cp1*bn1>cn1*bp1) ? -1 : bn0*cn1>bn1*cn0 ? 1 : 0) : 0

    это называется AviSynth - и это вполне нормальный скрипт, ибо другого пути там просто нет, да и альтернатив AviSynthy пока нет

    3.14159265, 12 Июля 2010

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

    +89

    1. 1
    pp = pp++;

    Что хотел сказать автор?...

    tinynick, 22 Июня 2010

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

    +89

    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
    void __fastcall TForm1::FormPaint(TObject *Sender)
    {
      for(int i=0;i<2;i++)
      {
        if(!White[i].Moves)
        {
          int j=0;
          for(int k=0;k<i;k++)
          {
            if(White[k].Position == White[i].Position)
            {
              j++;
            }
          }
          Image1->Canvas->MoveTo(Points[White[i].Position-1].X-20,Points[White[i].Position-1].Y - 30*j);
          Image1->Canvas->LineTo(Points[White[i].Position-1].X+20,Points[White[i].Position-1].Y - 30*j);
        }
      }
      //Image1->Canvas->LineTo(200,200);
    }

    Этот обработчик грузит проц. на 50 процентов и таймер не работает из-за него.
    Писал мой знакомый, который не любит продукты от борланда.
    В чем дерьмо? Думаю видно невооруженным глазом.

    fenryr, 30 Апреля 2010

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

    +89

    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
    #if __STDC_WANT_SECURE_LIB__
    _Check_return_opt_ _CRTIMP int __cdecl fscanf_s(_Inout_ FILE * _File, _In_z_ _Scanf_s_format_string_ const char * _Format, ...);
    #endif
    _Check_return_opt_ _CRTIMP int __cdecl _fscanf_s_l(_Inout_ FILE * _File, _In_z_ _Scanf_s_format_string_ const char * _Format, _In_opt_ _locale_t _Locale, ...);
    _Check_return_opt_ _CRTIMP int __cdecl fsetpos(_Inout_ FILE * _File, _In_ const fpos_t * _Pos);
    _Check_return_opt_ _CRTIMP int __cdecl fseek(_Inout_ FILE * _File, _In_ long _Offset, _In_ int _Origin);
    _Check_return_ _CRTIMP long __cdecl ftell(_Inout_ FILE * _File);
    
    _Check_return_opt_ _CRTIMP int __cdecl _fseeki64(_Inout_ FILE * _File, _In_ __int64 _Offset, _In_ int _Origin);
    _Check_return_ _CRTIMP __int64 __cdecl _ftelli64(_Inout_ FILE * _File);
    
    _Check_return_opt_ _CRTIMP size_t __cdecl fwrite(_In_count_x_(_Size*_Count) const void * _Str, _In_ size_t _Size, _In_ size_t _Count, _Inout_ FILE * _File);
    _Check_return_ _CRTIMP int __cdecl getc(_Inout_ FILE * _File);
    _Check_return_ _CRTIMP int __cdecl getchar(void);
    _Check_return_ _CRTIMP int __cdecl _getmaxstdio(void);

    Говнокод из Вермонда

    guest, 30 Июня 2009

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

    +88.2

    1. 1
    2. 2
    $objCity = new CMyCity();
    $objCity->__construct($arFieldValue['CITY_ID']);

    guest, 12 Мая 2009

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

    +88

    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
    procedure sr(var q, w: string; j, k: integer);
    begin
      for j := 1 to 100 do
      begin
        if ord(q[j]) - ord(w[j]) > 0 then begin for k := 1 to pos(' ', q) do write(q[k]);exit; end
        else if ord(q[j]) - ord(w[j]) < 0 then begin for k := 1 to pos(' ', w) do write(w[k]);exit; end;
      end;
      for k := 1 to pos(' ', w) do write(w[k]);
    end;
     
    procedure sr2(var q, w, e, r: string; j, k, p: integer);
    begin
      for j := 1 to 101 do
      begin
        if ord(q[j]) - ord(w[j]) > 0 then begin r := q;break; end
        else if ord(q[j]) - ord(w[j]) < 0 then begin r := w;break;end;
        inc(p);
      end;
      if p>100 then r:=w;
      for j := 1 to 100 do
      begin
        IF E[J]=' ' Then break;
        if ord(e[j]) - ord(r[j]) > 0 then begin for k := 1 to pos(' ', e) do write(e[k]);exit; end
        else if ord(e[j]) - ord(r[j]) < 0 then begin for k := 1 to pos(' ', r) do write(r[k]);exit; end;
      end;
      for k := 1 to pos(' ', r) do write(r[k]);
    end;
     
    var
      st, a, b, c, rd: string;
      i, s: integer;
     
    begin
      assign(input, 'input.txt'); reset(input);
      assign(output, 'output.txt'); rewrite(output);
      read(st);
      for i := 1 to 102
      do
      begin
        a := a + ' ';
        b := b + ' ';
        c := c + ' ';
      end;
      for i := 1 to length(st) do
        if st[i] = ' ' then inc(s)
        else
          case s of
            0: a[i] := st[i];
            1: b[i - pos(' ', a)] := st[i];
            2: c[i - pos(' ', a) - pos(' ', b)] := st[i];
          end;
      if (a=b) and (b=c) then for i := 1 to pos(' ', a) do write(a[i])
      else if (pos(' ', a) > pos(' ', b)) and (pos(' ', a) > pos(' ', c)) then for i := 1 to pos(' ', a) do write(a[i])
      else if (pos(' ', b) > pos(' ', a)) and (pos(' ', b) > pos(' ', c)) then for i := 1 to pos(' ', b) do write(b[i])
      else if (pos(' ', c) > pos(' ', b)) and (pos(' ', c) > pos(' ', a)) then for i := 1 to pos(' ', c) do write(c[i])
      else if (pos(' ', a) = pos(' ', b)) and (pos(' ', b) = pos(' ', c)) then sr2(a, b, c, rd, 0, 0, 0)
      else if pos(' ', a) = pos(' ', b) then sr(a, b, 0, 0)
      else if pos(' ', c) = pos(' ', b) then sr(c, b, 0, 0)
      else if pos(' ', a) = pos(' ', c) then sr(a, c, 0, 0);
    end.

    Выбор максимума из 3 целых длинных чисел

    AndreyZ, 17 Декабря 2014

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

    +88

    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
    function TCalc.getRewardItems(items : AnsiString; countItems : integer; userId : Integer; from:integer) : ISuperObject;
    var tmpFirstOdds : integer;
        strLines, extrLines : TStringList;
        strItems, strOdds, strOdds2: TIntegerList;
        i, j, tmpCountItems : integer;
        tmpOddsItems, sum : Integer;
        str: ansistring;
    begin
      Result := nil;
    
      // parse items line [id1,odd1],[id2,odd2],[id3,odd3]
      strLines := TStringList.Create;
      extrLines := TStringList.Create;
      strItems := TIntegerList.Create;
      strOdds := TIntegerList.Create;
      ExtractStrings(['[', ']'],[','], PChar(items), strLines);
      for i := 0 to strLines.Count - 1 do
      begin
        ExtractStrings([','],[' '], PChar(strLines[i]), extrLines);
        strItems.Add(StrToInt(extrLines[0]));
        strOdds.Add(StrToInt(extrLines[1]));
        extrLines.Clear;
      end;
    
      // calculate odds [a,b,c,d] as [a,a+b,a+b+c,a+b+c+d]
      sum := 0;
      strOdds2 := TIntegerList.Create;
      for i := 0 to strOdds.Count-1 do
      begin
        sum := sum + strOdds.Items[i];
        strOdds2.Add(sum);
      end;
    
      // select items
      str := '';
      for i := 0 to countItems - 1 do
      begin
        tmpFirstOdds := Random(101); // 0-100
        for j := 0 to strOdds2.Count-1 do
        begin
          if tmpFirstOdds < strOdds2.Items[j] then
          begin
            str := str + IntToStr(strItems[j]) + ',';
            break;
          end;
        end;
      end;
      str := '['+Copy(str,1,Length(str)-1)+']';
      // from monster
      if from=0 then Result := so('{"part":"battle","func":"itemsdropped","data":'+str+'}');
      // from chest
      if from=1 then Result := so('{"part":"battle","func":"itemsdroppedchest","data":'+str+'}');
      strLines.Free;
      extrLines.Free;
      strItems.Free;
      strOdds.Free;
      strOdds2.Free;
    end;

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

    Cynicrus, 24 Ноября 2014

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

    +88

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    9. 9
    with dm.Query do
        begin
          if Active then Close;
          //вот так оно работало до ввода параметров
          //dm.QStat.SQL.Text := 'select * from T_ORDER where (date between ''' + IntToStr(ys) + '-' + IntToStr(ms) + '-' + IntToStr(ds) + ''' and ''' + IntToStr(yf) + '-' + IntToStr(mf) + '-' + IntToStr(df) + ''')' ;
    
          SQL.Text := 'select * from T_ORDER where (date between :StartDate  and :FinishDate)';
          Parameters.ParamByName('StartDate').Value := IntToStr(ys) + '-' + IntToStr(ms) + '-' + IntToStr(ds);
          Parameters.ParamByName('FinishDate').Value := IntToStr(yf) + '-' + IntToStr(mf) + '-' + IntToStr(df);

    в комменте - код, ниже - его вменяемая замена

    knowy, 27 Октября 2014

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

    +88

    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
    program One;
    
    var
      a, b, c: integer;
    
    begin
      assign(input, 'input.txt'); reset(input);
      assign(output, 'output.txt'); rewrite(output);
      read(a);
      if a = 5 then
        Writeln('25')
      else if (a div 5 = 1) 
        then
        Writeln('Введите число, оканчивающееся на 5!')
      else begin
        b := a div 10;
        c := b * (b + 1);
        Writeln(c, '25');
      end;
    end.

    Dexius, 06 Октября 2014

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

    +88

    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
    var 
      s: string := '1 2 4 8 16 32 64 128 256 512';
      sum: integer;
      num,p: integer;
      numstr: string;
    begin
      sum := 0;
      while s.Length>0 do
      begin
        while s[1]=' ' do // Удаление лидирующих пробелов
          Delete(s,1,1);
        p := Pos(' ',s); // Поиск следующего пробела
        if p=0 then      // Если он не найден, то до конца строки находится последнее число
          p := s.Length;
        numstr := Copy(s,1,p);
        Delete(s,1,p);
        num := StrToInt(numstr);
        sum += num;
      end;
      writeln('Сумма чисел строки равна ',sum);
    end.

    "Pascal" не умеет в split?
    http://pascalabc.net/wiki/index.php/Строки_и_символы._Тексты_программ

    gost, 31 Марта 2014

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