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

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

    +84

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    int size = delete.count();
    for (int i = 1; i < (size + 1); i++) {
       deleteDelegation(i);
       i--;
       if (i == 0) break;
    }

    Задание: надо удалить все делегированные права.

    shainek, 25 Февраля 2015

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

    +84

    1. 1
    List selection = new ArrayList((s != null) ? s : new ArrayList());

    Больше мусора для бога сборщика мусора!

    someone, 05 Декабря 2014

    Комментарии (21)
  4. Java / Говнокод #16831

    +84

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    private static final int INT_5 = 5;
    private static final int INT_3 = 3;
    private static final int INT_4 = 4;
    private static final int INT_6 = 6;
    private static final int INT_7 = 7;
    private static final int INT_8 = 8;

    xaoc, 09 Октября 2014

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

    +84

    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
    type
      TSearchF = class(TThread)
      private
      protected
        procedure Execute; override;
      public
        Str: String; // думаю назначение обоих 
        Pause: Boolean; // параметров объяснять не надо
      end;
    
    и
    
    Код:
    
    
     procedure TSearchF.Execute;
    begin
      while not Terminated do
      begin
         if(Pause) then
         begin
            Sleep(10);
         end else
         begin
            FindFile(Str);
         end;
      end;
    end;

    http://www.programmersforum.ru/showthread.php?t=91543
    Без комментариев.

    brutushafens, 17 Июня 2014

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

    +84

    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
    {*********** PosEx ***********}
    function Posex(const substr,str:string; const startloc:integer):integer;
    {Search for "substr" in "str" starting at "startloc" return 0 or the start
     postion where "substr" was found}
    var
      i, j,k,ssLen, sLen, stop:integer;
      a:char;
    begin
      result:=0;
      ssLen:=length(substr);
      slen:=length(str);
      stop:=slen-sslen+1; {highest feasible start location for substring}
      if (ssLen=0) or (sslen>sLen) then exit;
      a:=substr[1];  {1st letter of substr}
      i:=startloc; {start search location}
      while (i<=stop) and (result=0) do
      begin
        while (i<=stop) and (a<>str[i]) do inc(i); {find the 1st letter}
        if i<=stop then
        begin
          if sslen=1 then  result:=i {It was a 1 character search, so we're done}
          else
          begin
            j:=2;
            k:=i-1; {back "K" up by 1 so that we can use K+j as the index to the string}
            while (j<=sslen) do
            begin {compare the rest of the substring}
              if (substr[j]<>str[k+j]) then break
              else inc(j); {The letter matched, go to the next+
                       {When we pass the substring end, "while" loop will terminate}
            end;
            if (j>sslen) then
            begin
              result:=i;
              exit;
            end
            else inc(i); {that search failed, look for the next 1st letter match}
          end;
        end;
      end;
    end;

    Несколько вложенных циклов - это НЕ может работать быстро.
    Для сравнения - функция PosEx из StrUtils.pas

    function PosEx(const SubStr, S: string; Offset: Cardinal = 1): Integer;
    var
    I,X: Integer;
    Len, LenSubStr: Integer;
    begin
    if Offset = 1 then
    Result := Pos(SubStr, S)
    else
    begin
    I := Offset;
    LenSubStr := Length(SubStr);
    Len := Length(S) - LenSubStr + 1;
    while I <= Len do
    begin
    if S[i] = SubStr[1] then
    begin
    X := 1;
    while (X < LenSubStr) and (S[I + X] = SubStr[X + 1]) do
    Inc(X);
    if (X = LenSubStr) then
    begin
    Result := I;
    exit;
    end;
    end;
    Inc(I);
    end;
    Result := 0;
    end;
    end;


    А вот что пишет автор:
    The Delphi "Pos" function searches for a
    substring within a string. Later versions of
    Delphi also include a "PosEx" function
    which
    starts the search at a given position so
    multiple calls can return all occurrences.

    This program tests DFF versions of these
    two
    functions. Pos was rewritten to provide a
    base
    of code for PosEx. And PosEx wll provide
    the
    missing function for versions of Delphi
    before
    Delphi 7.

    As an unexpected bonus, it appears that the
    DFF versions of Pos and Posex are slightly
    quicker than the D7 versions.

    brutushafens, 20 Апреля 2014

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

    +84

    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
    private final public static volatile transient synchronized protected InterceptorSingletonVisitor interceptorSingletonVisitor(AbstractDecoratorStrategyProxyObserverInterceptorBuilder abstractDecoratorStrategyProxyObserverInterceptorBuilder, AbstractVisitorAdvisorFacadeListener abstractVisitorAdvisorFacadeListener, VisitorFactoryFactoryBuilder visitorFactoryFactoryBuilder, VisitorProxyFacadeFactoryFactorySingletonAdvisorDecorator visitorProxyFacadeFactoryFactorySingletonAdvisorDecorator, AbstractAdvisorBuilderDecoratorInterceptor abstractAdvisorBuilderDecoratorInterceptor) {
    AbstractProxyAdvisor abstractProxyAdvisor = abstractFactoryFactoryDecorator.getListenerInterceptorFactoryFactory().getAbstractProxyAdvisor();
    AbstractVisitorAdvisorListenerStrategySingletonIteratorAdapterFactory abstractVisitorAdvisorListenerStrategySingletonIteratorAdapterFactory = new AbstractVisitorAdvisorListenerStrategySingletonIteratorAdapterFactory();
    abstractBeanAdvisorSingletonInterceptor.setAbstractFactoryFactoryAdvisorFacadeStrategy(this.abstractFactoryFactoryAdvisorFacadeStrategy);
    AbstractAdvisorProxyStrategyIteratorVisitorObserver abstractAdvisorProxyStrategyIteratorVisitorObserver = new AbstractAdvisorProxyStrategyIteratorVisitorObserver();
    
    if(abstractSingletonFacadeFactoryObserver.isInterceptorListenerFacade()) {
    iteratorProxyListenerFacadeBean.setAbstractStrategyBean(this.abstractStrategyBean);
    AbstractFactoryDecoratorBeanFacadeAdapterProxyAdvisorVisitor abstractFactoryDecoratorBeanFacadeAdapterProxyAdvisorVisitor = abstractBeanInterceptorIteratorListenerFactoryFactoryStrategyProxyObserver.getAbstractObserverFacadeListenerSingletonProxyAdvisorStrategyVisitor().getAbstractFactoryDecoratorBeanFacadeAdapterProxyAdvisorVisitor();
    abstractProxyBuilderVisitorSingleton.setIteratorAdvisorProxySingletonAdapter(this.iteratorAdvisorProxySingletonAdapter);
    
    if(abstractDecoratorAdapterVisitorProxyObserverIteratorBuilderFactory.isDecoratorFactoryFactoryFacade()) {
    visitorIteratorObserverProxyAdvisor.setAbstractObserverSingletonProxyAdvisorBuilderDecorator(this.abstractObserverSingletonProxyAdvisorBuilderDecorator);
    singletonFacadeAdapterListenerFactory.setAbstractIteratorInterceptorSingletonListenerAdvisorDecoratorBuilderFactoryFactory(this.abstractIteratorInterceptorSingletonListenerAdvisorDecoratorBuilderFactoryFactory);
    
    while(abstractFactoryAdapterSingletonFactoryFactory.isAbstractStrategyFactory()) {
    abstractAdapterBeanStrategySingletonAdvisorBuilderListenerFactory.setAbstractStrategyFactoryFactoryFacadeBuilderFactoryIteratorProxyObserver(this.abstractStrategyFactoryFactoryFacadeBuilderFactoryIteratorProxyObserver);
    abstractObserverAdapterFactoryFacadeDecoratorBuilderInterceptorFactoryFactory.setAdvisorIteratorFactoryProxyDecorator(this.advisorIteratorFactoryProxyDecorator);
    
    while(abstractFacadeListenerStrategyIteratorAdvisorSingletonProxyObserver.isVisitorDecoratorInterceptorIteratorAdapter()) {
    abstractProxyAdapterInterceptorObserverFactoryFactoryIterator.setSingletonFactoryFactoryProxyIteratorStrategy(this.singletonFactoryFactoryProxyIteratorStrategy);
    singletonInterceptorDecorator.setAbstractFactoryFactoryListenerBuilderAdvisorDecoratorFacade(this.abstractFactoryFactoryListenerBuilderAdvisorDecoratorFacade);
    visitorFactoryFactoryAdapterIteratorInterceptor.setAbstractIteratorVisitor(this.abstractIteratorVisitor);
    }
    }
    } else {
    abstractListenerInterceptorStrategyVisitorBeanFactorySingletonIterator.setAbstractProxyStrategy(this.abstractProxyStrategy);
    abstractProxyInterceptorSingletonFactoryFactory.setAbstractSingletonIterator(this.abstractSingletonIterator);
    }
    } else {
    singletonListenerFactoryFactoryIteratorProxy.setAbstractObserverProxyIteratorVisitor(this.abstractObserverProxyIteratorVisitor);
    }
    
    return new InterceptorSingletonVisitor();
    }

    laMer007, 13 Марта 2014

    Комментарии (55)
  8. Java / Говнокод #15375

    +84

    1. 1
    // TODO: Add comment here to explain what we do

    нашёл на прасторах праектуса %))

    Pepper-X, 06 Марта 2014

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

    +84

    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
    function Okruglenije(cislo: Currency; skolkonulei: Integer): string;
    var
    
      outs: string;
      rst, cel, zn: string;
      p: integer;
    begin
      outs := FloatToStr(cislo);
    
      p := Pos(',', outs) + 1;
    
      zn := Copy(outs, p, skolkonulei);
    
      cel := FloatToStr(trunc(cislo));
    
      if p > 1 then
        rst := Trim(cel + ',' + zn)
    
      else
        rst := Trim(cel);
    
      Okruglenije := rst;
    
    end;

    Процедура округления

    ka3ax, 04 Января 2014

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

    +84

    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
    88. 88
    89. 89
    90. 90
    uses crt;
    type point=record{точки}
               x,y:real;
               end;
         okr=record{окружности}
             x,y,r:real;
             end;
    const nmax=20;
    function Peres(a,b:point;c:okr):boolean;{пересекаются или нет}
    var s,ab,h:real;
    begin
    s:=abs(a.x*(b.y-c.y)+b.x*(c.y-a.y)+c.x*(a.y-b.y));{удвоенная площадь треугольника
    вершины которого центр окружности и 2 точки}
    ab:=sqrt(sqr(a.x-b.x)+sqr(a.y-b.y));{сторона, противоположная центру окружности}
    h:=s/ab;{высота на нее=расстояние от центра до прямой}
    Peres:=h<c.r;{если лно меньше радиуса, пересекаются}
    end;
    var a:array[1..nmax] of point;
        b:array[1..nmax] of okr;
        n,m,i,j,k,p,mx,imx,jmx:integer;
    begin
    clrscr;
    randomize;
    repeat
    write('Количество точек до ',nmax,' n=');
    readln(n);
    until n in [1..nmax];
    repeat
    write('Количество окружностей до ',nmax,' m=');
    readln(m);
    until m in [1..nmax];
    for i:=1 to n do
     begin
      a[i].x:=-10+random*21;
      a[i].y:=-10+random*21;
     end;
    for i:=1 to m do
     begin
      b[i].x:=-5+11*random;
      b[i].y:=-5+11*random;
      b[i].r:=5*random;
     end;
    writeln('Координаты точек:');
    write('X:');
    for i:=1 to n do
    write(a[i].x:6:2);
    writeln;
    write('Y:');
    for i:=1 to n do
    write(a[i].y:6:2);
    writeln;
    writeln;
    writeln('Параметры окружностей:');
    write('X:');
    for i:=1 to m do
    write(b[i].x:6:2);
    writeln;
    write('Y:');
    for i:=1 to m do
    write(b[i].y:6:2);
    writeln;
    write('R:');
    for i:=1 to m do
    write(b[i].r:6:2);
    writeln;
    writeln;
    mx:=0;
    imx:=0;
    jmx:=0;
    for i:=1 to n-1 do
    for j:=i+1 to n do
     begin
      k:=0;
      for p:=1 to m do
      if Peres(a[i],a[j],b[p]) then k:=k+1;
      if k>mx then
       begin
        mx:=k;
        imx:=i;
        jmx:=j;
       end;
     end;
    if mx=0 then write('Нет пересекающихся прямых и окружностей')
    else
     begin
      writeln('Максимальное число пересечений прямой с окружностями=',mx);
      write('Эта прямая проходит через точки (',a[imx].x:0:2,';',a[imx].y:0:2,') и (',a[jmx].x:0:2,';',a[jmx].y:0:2,')');
     end;
    readln
    end.

    Рекурсивная функций с циклами тройной вложенности

    Psilon, 20 Мая 2013

    Комментарии (13)
  11. Куча / Говнокод #12377

    +84

    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
    >                          +
                              +++
                            +++++++
                         ++---[>++++++
                      +>+++++ +++ ++>++++
                             +++++
                           ++>++++++
                        +++++>+++++++++
                   +++>+++>++ +++ +++>++++++
                             ++++>
                          +++++++++++
                      +>+++>+++++++++>+++
                 +++++++>++++++++++>++++++++++
           +>+++><<<<<<<<<<<<<<<<-]>++>--->++>++>+>+
                             +>-->
                             +>->+
    +>->+>--->++++>+++><<<<<<<<<<<<<<<<>.>.>.>.>.>.>.>.>.>.+
    ->.>.>.>.>.[-]++++++++++.>[-]<[>+++<-]>++.....>+++++++++
    +[>+++++>+++++>+++++>+++++><<<<<-]>>-->->+><<<<<>.>.>.>.

    С новым 2013м годом!

    Пусть в новом году вас обойдут стороной индусизмы, баги и крестобатхерты,
    а красивые решения, чистый код и годные фичи не заставят себя ждать!

    bormand, 31 Декабря 2012

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