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

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

    +93

    1. 1
    if (indSpec == false || indZone == false || (FRof != null && FRof == 2)) result = 1;

    Нашли в проекте вот такое "женское" условие. Видимо, префиксом "ind" автор намекала на своё происхождение.

    DukeGonzo, 15 Мая 2012

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

    +128

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>По колено в коде —  Говнокод.ру</title>
    
    <!-- Пару десятков строчек спустя -->
    
    <li><script type="text/javascript" src="http://reformal.ru/tab.js?title=%C3%EE%E2%ED%EE%EA%EE%E4.%F0%F3%3A+%EF%EE+%EA%EE%EB%E5%ED%EE+%E2+%EA%EE%E4%E5&amp;domain=govnokod&amp;color=adadad&amp;align=left&amp;charset=cp1251&amp;ltitle=%CE%F2%E7%FB%E2%FB&amp;lfont=Verdana, Geneva, sans-serif&amp;lsize=11px&amp;waction=0&amp;regime=1"></script></li>

    Чтобы решить проблему с кодировкой - нужно просто поменять charset=cp1251 на charset=utf8, вестимо.
    Но страйко который год не может.

    7ion, 13 Мая 2012

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

    +8

    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
    91. 91
    92. 92
    #include <stdio.h>
    #include <string>
    int main()
    {
    	freopen("input.txt","r",stdin);
            freopen("output.txt","w",stdout);
    	char s[100];
    	int n1 = 0,eq = 0,i = 0,o = 0,e = 0;
    	scanf("%s",&s);
    	int len;
    	len = strlen(s);
    	for(i = 0; i <= len; i++)
    	{
    		if ((s[i] == '+') || (s[i] == '-') || (s[i] == '/') || (s[i] == '*')) 
    		{
    			if (s[i-1] != '=')
    			{
    				n1 = i;
    				o = 1;
    			}
    				
    			
    			if ((n1 == '-') && (s[i-1] == '+') || (s[i-1] == '-') || (s[i-1] == '/') || (s[i-1] == '*'))
    			{
    				n1--;
    				o = 1;
    			}
    
    			
    		}
    		if (s[i] == '=')
    		{
    			eq = i;
    			e++;
    		}
    	}
    
    	if ((eq == 0) || (n1 == 0) || (e != 1) || (o != 1))
    	{
    		printf("ERROR");
    		return 0;
    	}
    	char* err ;
    	//begin copy-paste :(
    	char s1[100] = "0";
    	for(i = 0; i < n1; i++)
    	{
    		s1[i] = s[i];
    	}
    	long l1 = strtol(s1, &err, 10);
    	if (*err) 
    	{
    		printf("ERROR");
    		return 0;
    	}
    	//еще 10-15 строк
    	//end copy-paste :(
    	//begin new copy-paste :((
    	if (s[n1] == '+')
    	{
    		if (l1 + l2 == l3)
    		{
    			printf("YES");
    		} else 
    		{
    			printf("NO");
    		}
    	}
    	if (s[n1] == '/')
    	{
    		if (l2 != 0) 
    		{
    			if((l1 / l2 == l3) && (l1 % l2 == 0))
    			{
    				printf("YES");
    			} else 
    			{
    				printf("NO");
    			}
    		} else
    		{
    			printf("NO");
    		}
    
    
    	}
    	//Еще 10-15 строк
    	//end new copy-paste :((
    
    	
    	return 0;
    }

    А всего-то надо проверить верно ли тождество. (Тождество очень простое и состоит из числа, операции («+», «-», «*», «/»), числа, знака равенства и числа)

    bars66, 10 Мая 2012

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

    +121

    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
    minChunksSize=1000.0 -- 100.0
     
    facbig :: Integer -> Integer
    facbig n = 
            let 
                    divisionProportion = 0.9 -- 2.0/3.0
                    amountOfChunk = truncate $ logBase divisionProportion $ minChunksSize/fromIntegral n
                    proportions = map (divisionProportion^) [amountOfChunk, amountOfChunk-1 .. 1]
                    centralChunkResults = map product [
                            let
                                    begin = proportionToItemNumber 1 beginRangeProportion
                                    end = proportionToItemNumber 0 endRangeProportion
                            in
                            [begin..end] | (endRangeProportion, beginRangeProportion) <- zip proportions $ tail proportions ]
                    beginChunkResult = product [1 .. proportionToItemNumber 0 $ last proportions]
                    endChunkResult = product [proportionToItemNumber 1 $ head proportions .. n]
            in product $ beginChunkResult:endChunkResult:centralChunkResults
            where
                    proportionToItemNumber shift proportion =
                            shift + truncate ((1.0-proportion)*fromIntegral n)
     
    fac n = if n <= (truncate $ 3.0*minChunksSize)
            then product [1..n]
            else facbig n
     
    main = print $ length $ show $ fac 100000

    Вот так вот школота считают число цифр в факториале числа.

    HaskellGovno, 10 Мая 2012

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

    +70

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/product/compare.tpl')) {
    	$this->template = $this->config->get('config_template') . '/template/product/compare.tpl';
    } else {
    	$this->template = 'default/template/product/compare.tpl';
    }

    Спешите видеть в конце каждого контроллера OpenCart. Ох уж это MVC ради MVC...

    telnet, 08 Мая 2012

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

    +75

    1. 1
    2. 2
    3. 3
    4. 4
    require( "./configuration.php" );
    include( "./include.php" );
    $returned = @( );
    if ( ( $returned ) != @( "harper" ) )

    cthulhu25, 07 Мая 2012

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

    +86

    1. 1
    2. 2
    3. 3
    int createStageCycles = 0;
    createStageCycles = Integer.parseInt(strCycle);
    int nextVal = new Integer(createStageCycles) + 1;

    int двойного отжима

    zloizerg, 07 Мая 2012

    Комментарии (7)
  9. Python / Говнокод #10209

    −428

    1. 1
    2. 2
    3. 3
    4. 4
    url = request.get_full_path()
    if 'show_error' in url:
        show_param = url.split('?show_error=')
        error = show_param[1]

    Кусок кода из Django проекта
    Взяли индуса на работу. Вот так он достает GET параметры

    larikov, 07 Мая 2012

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

    +111

    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
    {$APPTYPE CONSOLE}
    {$R *.res}
    
    type
      TFTest = class
      public
        B: string;
        function Add(S: string = ''): TFTest;
        constructor Create(T: TFTest); overload;
      end;
    
    function TFTest.Add(S: string): TFTest;
    begin
      B := B + S;
      Exit(Self);
    end;
    
    var
      A: TFTest;
    
    constructor TFTest.Create(T: TFTest);
    begin
      B := T.B;
    end;
    
    begin
      writeln(TFTest.Create.Add('0')
        .Create((TFTest.Create(TFTest.Create(((((((TFTest.Create(TFTest.Create).Add('0')).Add('1').Create.Add('2')
        .Add as TObject).Create) as TFTest.ClassParent) as TFTest).Create).Add('3')).Add.Add('4').Create).Add('5')).Add('6')
        ).Add('7').B);
      readln;
    
    end.

    Кто правильно обьяснит этот код, получит... ничего получит :)

    ReckO, 05 Мая 2012

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

    +115

    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
    foreach (var sheet in paper.Decomposed)
    {
                    if (ct > 0 && sheet.Equals(paper.Decomposed[ct]))
                    {
                        paper.PaperPrice += paperPrice;
                        paper.PrintingPrice += printingPrice;
                        paper.PlatesPrice += platesPrice;
                        ct++;
                        continue;
                    }
                    ct++;
    ...
    }

    UniXoiD, 04 Мая 2012

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