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

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

    +18

    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
    template <typename T>
      struct canref {
        struct yes { uint8_t bytes[1]; };
        struct no  { uint8_t bytes[2]; };
        template <typename U>    static yes test(U*p);
        template <typename U>    static no  test(...);
        static const bool value = sizeof(test<T>(NULL)) == sizeof(yes);
      };
      template <typename T, int N, bool CanRef=canref<T>::value>
      class array; 
      // class for all types
      template <typename T, int N>
      class array <T,N,true>
      {
        struct Bytes
        {
          uint8_t bytes[sizeof(T)];
        };
        struct TStruct
        {
          T t;
          TStruct(T t):t(t){}
        };
    
        Bytes elements[N];
        int count;
        void copy_ctor (int index, const T& t)
        {
          new (&((*this)[index])) T(t);      
        }
        void copy (int index, const T& t)
        {
          (*this)[index] = t;
        }
    
        void dtor (int index)
        {
          (*this)[index].~T();
        }
      public:
        array () : count(0) {}
    
        ~array () 
        {
          resize(0);
        }
        T& operator [] (int index) 
        {
          assert (index>=0 && index<count);      
          return ((TStruct*)(&elements[index]))->t;
        }
        const T& operator [] (int index) const 
        {
          assert (index>=0 && index<count);      
          return ((TStruct*)(&elements[index]))->t;
        }
        template <int M>
        array (const array<T,M> &a)
        {
          assert(a.count<=N);
          count = a.count;
          for (int i=0; i<count; ++i)
            copyctor(i, a[i]);
        }
        template <int M>
        array& operator = (const array<T,M> &a)
        {
          if (this != &a)
          {
            if (count>a.count)
            {
              for (int i=0;       i<a.count; ++i) copy(i, a[i]);
              for (int i=a.count; i<count;   ++i) dtor(i);
              count = a.count;
            } else
            {
              assert(a.count<=N);
              int ocount = count;
              count = a.count;
              for (int i=0;      i<ocount; ++i) copy(i, a[i]);
              for (int i=ocount; i<count;  ++i) copy_ctor(i, a[i]);
            }
          }
        }
        int size() 
        {
          return count;
        }

    Скоро даже сратору станет очевидно откуда это.

    LispGovno, 10 Января 2014

    Комментарии (166)
  3. Python / Говнокод #11823

    −87

    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
    >>> r=range(16);print '\n'.join(' '*y+' '.join('# '[x&y>0] for x in r) for y in r)
    # # # # # # # # # # # # # # # #
     #   #   #   #   #   #   #   #  
      # #     # #     # #     # #    
       #       #       #       #      
        # # # #         # # # #        
         #   #           #   #          
          # #             # #            
           #               #              
            # # # # # # # #                
             #   #   #   #                  
              # #     # #                    
               #       #                      
                # # # #                        
                 #   #                          
                  # #                            
                   #

    1. Почему f(x, y) = 1-sign(x&y) даёт в результате треугольник Серпинского?
    2. Олимпиада: на вашем любимом языке написать программу, которая выводит аналогичный фрактал(см. код). Победит тот язык, программа на котором займёт наименьшее число символов. Нулевое приближение на Python - 78 символов.

    serpinski, 22 Сентября 2012

    Комментарии (166)
  4. JavaScript / Говнокод #10722

    +153

    1. 1
    http://pastebin.com/KNAhNqJC

    В связи с тем что толстота освоила новую тактику, выпущена очередная версия говнофильтра™.

    * поддержка скрытия постов. Увы, выкинуть пост из выдачи совсем не получится, так что при флуд-атаках будут пустые страницы.
    * альтернативный "мягкий" метод скрытия комментариев - белое на белом.
    * переписано на jQuery, раз уж оно есть на уютненьком ГК.

    Как обычно, заточено под Firefox+GreaseMonkey.

    Vindicar, 08 Июня 2012

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

    +192

    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
    <शैली श्रेणी>
    #समावेश <मानकपन.स>
    
    श्रेणी जानवर
    {
    खुला:
    	भव व्योम लिखो()
    	{
    		म_लिखो("यह एक जानवर है।\n");
    	}
    };
    
    श्रेणी शेर : खुला जानवर
    {
    खुला:
    	व्योम लिखो()
    	{
    		म_लिखो("शेर एक जानवर है।\n");
    	}
    };
    
    श्रेणी चीता : खुला जानवर
    {
    खुला:
    	व्योम लिखो()
    	{
    		म_लिखो("चीता एक जानवर है।\n");
    	}
    };
    
    पूर्णांक मुख्य()
    {
    	जानवर ज, *ज१;
    	शेर श;
    	चीता च;
    
    	ज.लिखो();
    	श.लिखो();
    	च.लिखो();
    
    	ज१=&ज;
    	ज१->लिखो();
    	ज१=&श;
    	ज१->लिखो();
    	ज१=&च;
    	ज१->लिखो();
    
    	वापस 0;
    }

    Вот вы все говорите про индусский код, а он на самом деле вот такой! Мне кажется, простой и логичный!

    (Дистрибутив на http://hindawi.in/en_US/download.php)

    nil, 06 Июня 2010

    Комментарии (166)
  6. C++ / Говнокод #27391

    0

    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
    template<typename T>
    class SharedPtr {
        T* value;
        int* ref_count;
    
    public:
        SharedPtr(T* value) : value(value) {
            ref_count = new int;
            *ref_count = 1;
        }
    
        SharedPtr(const SharedPtr& other) {
            value = other.value;
            ref_count = other.ref_count;
            (*ref_count)++;
        }
    
        SharedPtr(SharedPtr&& other) {
            value = other.value;
            ref_count = other.ref_count;
            other.ref_count = nullptr;
        }
    
        ~SharedPtr() {
            if (ref_count == nullptr) {
                return;
            }
    
            if (*ref_count == 1) {
                delete value;
                delete ref_count;
            } else {
                (*ref_count)--;
            }
        }
    
        T& operator *() const {
            return *value;
        }
    
        T* operator ->() const {
            return value;
        }
    };

    Реалейзовал минимальную версию shared_ptr. Есть ошибки/замечания?

    https://ideone.com/g7gqBM

    3_dar, 04 Мая 2021

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

    +158

    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
    <?php
    define("LOGIN", "login");
    define("PASSWORD", "password");
    define("BASE", "base");
    define("HOST", "IP");
    
    $table = "table";
    
    $err_name = "Вы не написали свое имя! <br />";
    $err_text = "Вы не написали текст! <br />";
    $err_email = "Вы не указали свой email! <br />";
    
    $conn = mysql_connect(HOST, LOGIN, PASSWORD) or die ('соединение с БД установить не удалось!');
    $db = mysql_select_db(BASE, $conn) or die ('проверьте наличие БД!');
    
    $stop = 0;
    if (isset($_POST['save'])) {
     if ((strlen($_POST['name']) !=0) && (strlen($_POST['text']) !=0) && (strlen($_POST['email']) !=0)) {
     
      $name = $_POST['name'];
      $text = $_POST['text'];
      $email = $_POST['email'];
      if (strlen($_POST['url']) !=0) {
        $url = $_POST['url'];
        $create = mysql_query("INSERT INTO $table VALUES (NULL, '$name', '$text', '$email', '$url')", $conn) or die ('запрос в БД не выполнен!');
      $stop = 1 ;
      }
      if ($stop != 1) {
       $create = mysql_query("INSERT INTO $table VALUES (NULL, '$name', '$text', '$email', NULL)", $conn) or die ('запрос в БД не выполнен!');
      } 
     }
    
    }
    
    if (error('name')) {
    echo $err_name;
    }
    
    if (error('text')) {
    echo $err_text;
    }
    
    if (error('email')) {
    echo $err_email;
    }
    
    
    function error($err) {
    return (isset($_POST['save']) && strlen($_POST[$err]) == 0);
    }
    
    $result = mysql_query("SELECT * FROM $table", $conn) or die ('Выбранная таблица не существует!');
    
    
    $stroki = mysql_num_rows($result);
    $stolb = mysql_num_fields($result);
    
    
    for ($i=0; $i<$stroki; $i++) {
    $s = mysql_fetch_row($result);
     for ($j=0; $j<$stolb; $j++) {
     $massiv[$i][$j] = $s[$j];
     }
    }
    
    for ($i=0; $i<$stroki; $i++) {
     for ($j=0; $j<$stolb; $j++) {
     echo $massiv[$stroki-$i-1][$j] . " ";
     }
    echo "<br />";
    }
    
    if (isset($_POST['clear'])) {
    $delete = mysql_query("TRUNCATE TABLE $table", $conn) or die ('запрос на удаление выполнить не удалось!');
    echo "<br />" . "<hr />" . "Все данные стерты!" . "<hr />" . "<br />";
    }
    
    mysql_close($conn);
    
    	echo "<form method=\"POST\">\n";
    	echo "<table border=\"1\" cellpadding=\"5\" cellspacing=\"5\">\n";
    	echo "<tr><td>Ваше имя</td><td><input type=\"text\" name=\"name\" /></td></tr>\n";
    	echo "<tr><td>Ваш email</td><td><input type=\"text\" name=\"email\" /></td></tr>\n";
    	echo "<tr><td>Ваша домашняя страница (URL)</td><td><input type=\"text\" name=\"url\" /></td></tr>\n";
    	echo "<tr><td>Текст сообщения</td><td><textarea name=\"text\"></textarea></td></tr>\n";
    	echo "<tr><td colspna=\"2\"><input type=\"submit\" name=\"save\" value=\"Отослать\"/></td></tr>\n";
    	echo "<tr><td colspna=\"2\"><input type=\"submit\" name=\"clear\" value=\"Очистить\"/></td></tr>\n";
    
    ?>

    гостевая книга (php +mysql)

    mihailhouse, 17 Ноября 2010

    Комментарии (165)
  8. PHP / Говнокод #4533

    +187

    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
    function get_rand_symbols($numeric) { 
    
       if($numeric == '1') { return 'п'; }
       if($numeric == '2') { return 'р'; }
       if($numeric == '3') { return 'о'; }
       if($numeric == '4') { return 'к'; }
       if($numeric == '5') { return 'е'; }
       if($numeric == '6') { return 'а'; }
       if($numeric == '7') { return 'д'; }
       if($numeric == '8') { return 'е'; }
       if($numeric == '9') { return 'й'; }
       if($numeric == '10') { return 'в'; }
       if($numeric == '11') { return 'м'; }
       if($numeric == '12') { return 'л'; }
       if($numeric == '13') { return 'с'; }
       if($numeric == '14') { return 'т'; }
       if($numeric == '15') { return 'у'; }
       if($numeric == '16') { return 'н'; }
       if($numeric == '17') { return 'ш'; }
       if($numeric == '18') { return 'х'; }
       if($numeric == '19') { return 'щ'; }
       if($numeric == '20') { return 'ъ'; }
       if($numeric == '21') { return 'ю'; }
       if($numeric == '22') { return 'б'; }
       if($numeric == '23') { return 'я'; }
       if($numeric == '24') { return 'ц'; }
       if($numeric == '25') { return 'ч'; }
       if($numeric == '26') { return 'ё'; }
       if($numeric == '27') { return 'э'; }
       if($numeric == '28') { return 'з'; }
       if($numeric == '29') { return 'и'; }
       if($numeric == '30') { return 'ы'; }
      }
      function all_rand() {
      return get_rand_symbols(rand(1, 30)).get_rand_symbols(rand(1, 30)).get_rand_symbols(rand(1, 30)).get_rand_symbols(rand(1, 30)).get_rand_symbols(rand(1, 30)).get_rand_symbols(rand(1, 30)).get_rand_symbols(rand(1, 30)).get_rand_symbols(rand(1, 30)).get_rand_symbols(rand(1, 30)).get_rand_symbols(rand(1, 30)).get_rand_symbols(rand(1, 30)).get_rand_symbols(rand(1, 30)).get_rand_symbols(rand(1, 30)).get_rand_symbols(rand(1, 30)).get_rand_symbols(rand(1, 30)).get_rand_symbols(rand(1, 30)).get_rand_symbols(rand(1, 30)).get_rand_symbols(rand(1, 30)).get_rand_symbols(rand(1, 30)).get_rand_symbols(rand(1, 30)).get_rand_symbols(rand(1, 30)).get_rand_symbols(rand(1, 30)).get_rand_symbols(rand(1, 30)).get_rand_symbols(rand(1, 30));
      }

    случайная строка с русскими символами

    Shiz89, 04 Ноября 2010

    Комментарии (165)
  9. PHP / Говнокод #3410

    +164

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    mysql_query("INSERT INTO `classes` (`name`) VALUES('".$_POST["class_name"]."')");
    		$Mresult=mysql_query("SELECT MAX(`id`) FROM `classes`");
    		$row=mysql_fetch_row($Mresult);
    		$class_num=$row[0];
    		$date1=$_POST["class_start"];
    		$date2=$_POST["class_end"];
    		mysql_query("CREATE TABLE `class_".$class_num."_lessons` (`id` INT, `data` TEXT)");
    		mysql_query("CREATE TABLE `class_".$class_num."_video` (`id` INT, `data` TEXT)");
    		mysql_query("CREATE TABLE `class_".$class_num."_ege` (`id` INT, `data` TEXT)");
    		mysql_query("CREATE TABLE `class_".$class_num."_rasp` (`id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY, `data` TEXT)");

    DSL88, 07 Июня 2010

    Комментарии (165)
  10. Куча / Говнокод #27638

    +1

    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
    .chamfer { 
      display: table;
      border-collapse: separate;
      empty-cells: show;
      background: transparent;
      display: inline-block;
      margin-bottom: 25px;
      margin-right: 25px;
      vertical-align: top;}
    .chamfer .row { 
      display: table-row;}
    .chamfer .boxcontent {
      display: table-cell;
      background: #FFFFFF;
      font-size: 24px;
      vertical-align: middle;
      min-width: 200px;
      width: 200px;
      height: 173px;}
    .chamfer .transparentbox {
      display: table-cell; 
      background: transparent;
      font-size: 24px;
      vertical-align: middle;
      min-width: 200px;
      width: 200px;}
    .chamfer .row .north-west { 
      display: table-cell;
      border: 100px solid transparent;
      border-top-width: 0px;
      border-right-width: 0px;
      border-bottom: 173px solid #FFF;
      width: 0px;}
    .chamfer .row .north-east { 
      display: table-cell;
      border: 100px solid transparent;
      border-top-width: 0px;
      border-left-width: 0px;
      border-bottom: 173px solid #FFF;
      width: 0px;}
    .chamfer .row .south-west { 
      display: table-cell;
      border: 100px solid transparent;
      border-bottom-width: 0px;
      border-right-width: 0px;
      border-top: 173px solid #FFF;
      width: 0px;}
    .chamfer .row .south-east { 
      display: table-cell;
      border: 100px solid transparent;
      border-bottom-width: 0px;
      border-left-width: 0px;
      border-top: 173px solid #FFF;
      width: 0px;}
    .chamfer .row3 .north-west { 
      border: 100px solid yellow;
      border-top-width: 0px;
      border-right-width: 0px;
      border-bottom: 173px solid red;}
    .chamfer .row3 .north-east { 
      border: 100px solid yellow;
      border-top-width: 0px;
      border-left-width: 0px;
      border-bottom: 173px solid red;}
    .chamfer .row2 .south-west { 
      border: 100px solid yellow;
      border-bottom-width: 0px;
      border-right-width: 0px;
      border-top: 173px solid #FFF;}
    .chamfer .row2 .south-east { 
      border: 100px solid yellow;
      border-bottom-width: 0px;
      border-left-width: 0px;
      border-top: 173px solid #FFF;}
    .chamfer .row4 .south-west { 
      border: 100px solid transparent;
      border-bottom-width: 0px;
      border-right-width: 0px;
      border-top: 173px solid red;}
    .chamfer .row4 .south-east { 
      border: 100px solid transparent;
      border-bottom-width: 0px;
      border-left-width: 0px;
      border-top: 173px solid red;}
    .chamfer .row2 .transparentbox, .chamfer .row3 .transparentbox {
      background: yellow;
      height: 173px;}
    .chamfer .row3 .boxcontent, .chamfer .row4 .boxcontent {
      background: red;
      height: 173px;}
    body { 
      color: #3B3A37;
      background-color: olive;}

    Реальный пример шестиугольных блоков (в виде сот) на чистом CSS2.

    Страница в действии:
    https://output.jsbin.com/xewelufoda/

    CEHT9I6PbCKuu_nemyx, 01 Сентября 2021

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

    +7

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    console.log(parseInt(0.5)); // 0
    console.log(parseInt(0.05)); // 0
    console.log(parseInt(0.005)); // 0
    console.log(parseInt(0.0005)); // 0
    console.log(parseInt(0.00005)); // 0
    console.log(parseInt(0.000005)); // 0
    console.log(parseInt(0.0000005)); // 5

    https://ideone.com/YMWUGq

    Возможно баян, спижжено с https://vk.com/wall-72495085_1267978

    3_dar, 17 Августа 2021

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