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

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

    +163

    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
    function retPercByAct($num,$economy) { //50% discount => economy=0 => 15%
      $t='15/5 0-49,
      16/6 50-100,
      17/7 101-200,
      18/8 201-350,
      19/9 351-500,
      20/10 601-1000,
      21/11 1001-500000,';
      $t=explode(',',$t);
      foreach($t as $k=>$v) {
        $v=trim($v);
        list($perc,$nums)=explode(' ',$v);
        $nums=explode('-',$nums);
        if($nums[0]<=$num && $nums[1]>=$num) {
          $perc=explode('/',$perc);
          if(!$economy) $percR=$perc[0]; else $percR=$perc[1];
          break;
        }
      }
      return $percR;
    }

    Вот, встретилось в поддерживаемом мной проекте.

    segoddnja, 20 Июня 2011

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

    +131

    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
    (defparameter n 2)
    (setf middle (make-array 2 :initial-element 0))
    (defparameter v 7)
    (setf tr (make-array `(,(+ 1 n) ,n) :initial-element 4))
    (setf ftr (make-array 3 :initial-element 1))
    (defun pow (x n)
    (cond((= n 0) 1)((= n 1) x)(T (* x (pow x (- n 1))))))
    (defun f1 (x y)
    (+ (* (pow v 2) (pow x 2))
    (* (/ v (+ v 1)) x)
    (* 15 (+ v 1) (pow y 2))
    (* -1 2 v y) (* 4 v)))
    
    (defun sigma1 (a)
    (* a (/ (+ (sqrt (+ n 1)) (- n 1))
    (* n (sqrt 2))) ))
    
    (defun sigma2 (a)
    (* a (/ (+ (sqrt (+ n 1)) -1)
    (* n (sqrt 2))) ))
    
    (defun setp (a)
    (loop for i from 1 to n do
    (loop for j from 0 to (- n 1) do
    (cond
    ((= (- i 1) j) (setf (aref tr i j) (+ (aref tr 0 0) (sigma2 a))))
    (T (setf (aref tr i j) (+ (aref tr 0 1) (sigma1 a))))))))
    
    (defun evalfun ()
    (loop for i from 0 to n do
    (setf (aref ftr i) (f1 (aref tr i '0) (aref tr i '1)))
    (format t "The functions in dot ~$:~$~$" `(,(aref tr i '0) ,(aref tr i '1)) (aref ftr i) #\newline))
    (setf ftr (sort ftr #'<)))
    
    (defun midp()
    (loop for i from 0 to n do
    (cond
    ((= (aref ftr n) (f1 (aref tr i '0) (aref tr i '1)))
    (setq tp i))))
    
    (setf middle (make-array n :initial-element 0))
    (loop for i from 0 to n do
    (cond
    ((/= i tp)
    (setf (aref middle 0) (+ (aref middle 0) (aref tr i 0)))
    (setf (aref middle 1) (+ (aref middle 1) (aref tr i 1))))))
    (setf (aref middle 1) (/ (aref middle 1) 2))
    (setf (aref middle 0) (/ (aref middle 0) 2))
    (format t "The weight center in ~$,~$" (aref middle 0) (aref middle 0))
    (princ #\newline))
    
    (defun newp()
    (setf (aref tr tp 0) (- (aref middle 0) (aref tr tp 0)))
    (setf (aref tr tp 1) (- (aref middle 1) (aref tr tp 1))))
    (defun prpolinom()
    (format t "Polinom has this dots:~$" #\newline)
    (loop for i to n do
    (loop for j to (- n 1) do
    (format t "|~$|" (aref tr i j)))
    (princ #\newline)))
    
    (setq c 1)
    (defun mloop(a)
    (setp a)
    (defun subloop()
    (setq c (+ c 1))
    (setf tmiddle (make-array n :initial-element 0))
    (loop for i to (- n 1) do
    (setf (aref tmiddle i) (aref middle i)))
    (evalfun)
    (midp)
    (newp)
    (prpolinom)
    
    (cond
    ((and (= (aref tmiddle 0) (aref middle 0)) (= (aref tmiddle 1) (aref middle 1)))(mloop (/ a 2)))
    ((> a 0.01) (subloop) (format t "Iteration ~$~$" c #\newline))))
    (subloop))
    (mloop 2)

    симплекс метод на Common Lisp=)

    zura, 20 Июня 2011

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

    +171

    1. 1
    const_cast<TRefalAbstract*>(this)=new TRefal();

    Говногость, 18 Июня 2011

    Комментарии (24)
  5. Си / Говнокод #6884

    +130

    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
    93. 93
    94. 94
    MACROFIRE-MACRO 5.0.0
    
    [Info]
    Name = 
    Hotkey = 
    Repeat = 1
    
    [Macro]
    ButtonsPress = Circle
    Delay = 66
    ButtonsRelease = Circle
    Delay = 83
    ButtonsPress = Circle
    Delay = 83
    ButtonsRelease = Circle
    Delay = 50
    ButtonsPress = Circle
    Delay = 66
    ButtonsRelease = Circle
    Delay = 66
    ButtonsPress = Circle
    Delay = 83
    ButtonsRelease = Circle
    Delay = 66
    ButtonsPress = Down
    Delay = 50
    ButtonsPress = Right
    Delay = 83
    ButtonsRelease = Down
    ButtonsPress = Square
    Delay = 116
    ButtonsRelease = Right
    ButtonsRelease = Square
    Delay = 266
    ButtonsPress = RTrigger
    Delay = 83
    ButtonsRelease = RTrigger
    Delay = 50
    ButtonsPress = Circle
    Delay = 66
    ButtonsRelease = Circle
    Delay = 83
    ButtonsPress = Circle
    Delay = 66
    ButtonsRelease = Circle
    Delay = 66
    ButtonsPress = Circle
    Delay = 66
    ButtonsRelease = Circle
    Delay = 49
    ButtonsPress = Circle
    Delay = 83
    ButtonsRelease = Circle
    Delay = 66
    ButtonsPress = Circle
    Delay = 50
    ButtonsRelease = Circle
    Delay = 66
    ButtonsPress = Circle
    Delay = 100
    ButtonsChange = Down
    Delay = 83
    ButtonsPress = Right
    Delay = 66
    ButtonsRelease = Down
    Delay = 100
    ButtonsPress = Triangle
    ButtonsRelease = Right
    Delay = 83
    ButtonsRelease = Triangle
    Delay = 917
    ButtonsPress = Down
    Delay = 200
    ButtonsPress = Circle
    Delay = 83
    ButtonsRelease = Circle
    Delay = 66
    ButtonsPress = Circle
    Delay = 66
    ButtonsRelease = Circle
    Delay = 83
    ButtonsPress = Circle
    Delay = 133
    ButtonsRelease = Circle
    Delay = 50
    ButtonsRelease = Down
    Delay = 83
    ButtonsPress = Left
    ButtonsPress = Up
    Delay = 166
    ButtonsChange = Left + Circle
    ButtonsRelease = Left
    Delay = 116
    ButtonsRelease = Circle

    Lambda-11 Challenge 6

    minlexx, 07 Июня 2011

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

    +165

    1. 1
    if ($k == 'changed' && ($v == '' || $v=='0000-00-00 00:00:00')) $v = 'Не изменялся';

    skad0, 06 Июня 2011

    Комментарии (24)
  7. Си / Говнокод #6819

    +145

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    unsigned int userID;
    ...
    userID = -1;
    ...
    if( userID < 0 )

    bred, 02 Июня 2011

    Комментарии (24)
  8. Куча / Говнокод #6779

    +135

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    9. 9
    <div id="pointer_div">jQuery16104518015997745993=Object { events={...}}
    <div style="display: block; background: url("http://localhost/first/coord_mouse_on_pic/3/cr.gif") repeat scroll 0% 0% transparent; position: relative; padding: 0px; width: 615px; height: 417px;">
    <map id="htmlmap_com_4" name="htmlmap_com_4">jQuery16104518015997745993=Object { events={...}}
    <div id="myCanvas" style="position: relative; margin: 0px; padding: 0px;"></div>
    <div style="position: absolute; left: 424px; top: 195px; width: 2px; height: 2px; clip: rect(0pt, 2px, 2px, 0pt); padding: 0px; margin: 0px; background-color: red; overflow: hidden; opacity: 0.8;"></div>
    <div style="position: absolute; left: 426px; top: 195px; width: 2px; height: 2px; clip: rect(0pt, 2px, 2px, 0pt); padding: 0px; margin: 0px; background-color: red; overflow: hidden; opacity: 0.8;"></div>
    <div style="position: absolute; left: 424px; top: 197px; width: 4px; height: 2px; clip: rect(0pt, 4px, 2px, 0pt); padding: 0px; margin: 0px; background-color: red; overflow: hidden; opacity: 0.8;"></div>
    <div style="position: absolute; left: 424px; top: 197px; width: 2px; height: 0px; clip: rect(0pt, 2px, 0px, 0pt); padding: 0px; margin: 0px; background-color: red; overflow: hidden; opacity: 0.8;"></div>
    </div>

    -

    vulkan, 29 Мая 2011

    Комментарии (24)
  9. C# / Говнокод #6773

    +120

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    using System;
    
    class C
    {
        static void Main()
        {
            क्ष(0);
        }
    
        static void क्‍ष(int x) { Console.WriteLine(1); }
        static void क्ष(object x) { Console.WriteLine(2); }
    }

    Что будет напечатано ?


    Оч понравилось, нашел на простора интырнета (пардон если повтор)

    glilya, 28 Мая 2011

    Комментарии (24)
  10. JavaScript / Говнокод #6598

    +161

    1. 1
    var ptzReq = auction.responseText.slice(auction.responseText.indexOf('id="ptzReq'+id+'"')+18+id.toString().length, auction.responseText.indexOf('id="ptzReq'+id+'"')+51+id.toString().length);

    Зато здесь хотя-бы нет jQuery.

    popoffka, 08 Мая 2011

    Комментарии (24)
  11. JavaScript / Говнокод #6555

    +162

    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
    function Turn(id, mode) {
     if(document.layers || document.all) {
      if(mode)
       eval("setTimeout(\"On(" + id + ");\",100)");
      else
       eval("setTimeout(\"Off(" + id + ");\",100)");
     }
    }
    
    function On(id){
     if(occupied_header[id]) {
      if(document.all) {
        eval("menu" + id).style.visibility = 'visible';
        eval("menu" + id).style.left = mmm.offsetLeft+9;
    
      }
      else
      if(document.layers) {
       eval("document.layers['menu" + id + "']").visibility = "show";
      }
     }
    }
    
     function Off(id){
      if(!occupied_menu[id] && !occupied_header[id]) {
       name = 'i' + id;
       if(document.all) {
        eval("menu" + id).style.visibility = 'hidden';
       }
       else if(document.layers) {
        eval("document.layers['menu" + id + "']").visibility = "hide";
       }
      }
     }

    moonie, 05 Мая 2011

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