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

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

    +2

    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
    class pool_exeption: public std::exception
    {
        virtual  const char* what() const throw()
        {
            return "Pool out of bounds";
        }
    }pool_out_of_bounds;
    class pool_exeption2: public std::exception
    {
        virtual  const char* what() const throw()
        {
            return "Pool block is too small";
        }
    }pool_small_block;

    А потом эти исключения кидаются по значению: throw pool_out_of_bounds;
    virtual const char* WAT()

    Yuuri, 18 Октября 2013

    Комментарии (49)
  3. C++ / Говнокод #13851

    +2

    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
    #if defined(_WIN32) || defined(_WIN64)
         size_t size = message.size();
         size_t size_buf = 1015;
    
         size_t pointer = 0;
         for (int i = 0; i < (size/size_buf) + 1 ; i++){
             
             /*Делаем для красивого вывода. Пробел всегда один байт.
              *Потому сматываем указатель буфера до первого пробела.*/
             int buf = size_buf;
             while (message[pointer+buf] != ' ')
                 buf--;
             
             /*Здесь лечится косяк MinGw, буфер принимает по 1к байтов.
              *Лечение производим создавая дополнительные буферы.*/
             istringstream ss(message.substr(pointer,buf) );
             std::cout << ss.rdbuf();
             
             pointer += buf;
         }
    #else
         std::cout << message;
    #endif

    Похоже плохая сборка MinGw.
    http://govnokod.ru/13094

    crastinus, 26 Сентября 2013

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

    +2

    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
    double vvod (double a1, double a2, double a3) {
     
    // a1=a a2=b a3=c
     
    	cout<<"Введите значение коэфицента a: ";
    	cin>>a1;
    	cout<<endl;
    	cout<<"Введите значение коэфицента b: ";
    	cin>>a2;
    	cout<<endl;
    	cout<<"Введите значение коэфицента c: ";
    	cin>>a3;
    	cout<<endl;
    	return (a1);
    	return (a2);
    	return (a3);
    }

    Оказывается в С++ можно возвращать 3 значения из функции
    http://ideone.com/tGWRpl - полная версия.

    pabloid, 05 Сентября 2013

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

    +2

    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
    template <typename A, typename B> 
    class ololo 
    {
    };
    
    template <typename A>
    class ololo <A, int>
    {
    };
    
    template <typename A>
    void bububu ()
    {
    }
    
    template <>
    void bububu <int> ()
    {
    }
    
    template <typename A, typename B> 
    void kokoko  ()
    {
    }
    
    template <typename A>
    void kokoko <A, int> ()
    {
    }

    http://www.gamedev.ru/flame/forum/?id=169781
    tarasboproblemi

    LispGovno, 29 Ноября 2012

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

    +2

    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
    auto addition = [] (double a, double b) { return a + b; };
    
    auto substruction = [] (double a, double b) { return a - b; };
    
    auto divide = [] (double a, double b) { return a / b; };
    
    auto multiplie = [] (double a, double b) { return a * b; };
    
    typedef std::function<double (double, double)> DoubleFunc;
    
    int main()
    {
        std::vector<DoubleFunc> funcVector;
    
        funcVector.push_back(addition);
        funcVector.push_back(substruction);
        funcVector.push_back(multiplie);
        funcVector.push_back(divide);
    
        std::for_each(funcVector.begin(), funcVector.end(), []
        (DoubleFunc func)
        {
            std::cout << func(3.14159, 100500) << std::endl;
        });
    
        system("pause");
        return 0;
    }

    А ваш язык такое сможет:)? (я о delphi, java, etc.)
    Кстати, если писать все в таком духе, то параллелиться прога будет безболезненно:), правда это уже какой-то хацкель/лисп...

    suc-daniil, 30 Июля 2012

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

    +2

    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 <stdlib.h>
    #include <unistd.h>
    #include <string.h>
    #include <sys/types.h>
    #include <sys/socket.h>
    #include <netinet/in.h>
    #include <netdb.h> 
    #include <iostream>
    #include <vector>
    #include <string>
    using namespace std;
    struct user_data{
      char user_name[100];
      char host_name[100];
    }cuser;
    char file_path[100000];
    int sockfd;
    void error(const char *msg){
        perror(msg);
        exit(0);
    }
    char s[128];vector<user_data> users;
    int main(int argc, char *argv[]){
        int portno, n;struct sockaddr_in serv_addr;
        struct hostent *server;
        char buffer[256];
        static char file_name[256];
        if (argc < 2) {
           fprintf(stderr,"usage %s hostname port\n", argv[0]);
           exit(0);
        }
        portno = atoi(argv[1]);
        while(getchar()!='q'){
        sockfd = socket(AF_INET, SOCK_STREAM, 0);
        if (sockfd < 0) 
            error("ERROR opening socket");
        gethostname(s, 128);
        server = gethostbyname(s);
        if (server == NULL) {
            fprintf(stderr,"ERROR, no such host\n");
            exit(0);
        }
        bzero((char *) &serv_addr, sizeof(serv_addr));
        serv_addr.sin_family = AF_INET;
        bcopy((char *)server->h_addr, 
             (char *)&serv_addr.sin_addr.s_addr,
             server->h_length);
        serv_addr.sin_port = htons(portno++);
        if (connect(sockfd,(struct sockaddr *) &serv_addr,sizeof(serv_addr)) < 0) 
            error("ERROR connecting");
        bzero(buffer,256);
        n = write(sockfd,buffer,strlen(buffer));
        if (n < 0) 
             error("ERROR writing to socket");
        bzero(buffer,256);
        n = read(sockfd,buffer,255);
        if (n < 0) 
             error("ERROR reading from socket");
        int sf=0;
        for(int i=0;i<=strlen(buffer)-1;i++){
         if(buffer[i]=='@'){
          sf=i; 
         }
         if(sf==0){
          cuser.user_name[i]=buffer[i]; 
         } else {
          cuser.host_name[i-sf]=buffer[i+1]; 
         }
        }
        users.push_back(cuser);
         cout << cuser.user_name << " hostname: " << cuser.host_name << endl;
        printf("Enter file name:\n");
        fgets(file_name,255,stdin);
            n = write(sockfd,file_name,255);
        if (n < 0) 
             error("ERROR writing to socket");
         bzero(file_name,256);
         n = read(sockfd,file_path,100000);
        if (n < 0) 
             error("ERROR reading from socket");
        printf("\n%s\n",file_path);
        memset(file_path,'\0',100000);
         close(sockfd);
        }
        printf("\n\tRegistered users\n");
       for(int i=0; i < users.size(); i++)
       {
          cout << users[i].user_name << " hostname: " << users[i].host_name << endl;
       }
        close(sockfd);return 0;
    }

    Регистрация клиента на сервере

    AliceGoth, 23 Июля 2012

    Комментарии (33)
  8. C# / Говнокод #311

    +1.1

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    while (true) {
        try {
            break;
        }
        catch {
    
        }
    }

    интересно сработает?

    guest, 30 Декабря 2008

    Комментарии (4)
  9. Haskell / Говнокод #29148

    +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
    (defun sbcl-vrt-simd-pntr (a f fa &aux (defun (progn (defmacro << (x y) `,(ash x y)) (defmacro >> (x y) `,(ash x (- y))) (defmacro ~ (x) `(lognot ,x))))
                                           (if (progn (labels ((t (a f fa) (declare (type integer a)
                                                                                    (type (function (integer (function () (values)) (pointer single-float)) integer) f)
                                                                                    (type (array real (*)) fa))
                                                                           (declaim (optimize (speed (the (list integer (*)) '(-1 0 1))) (debug 0) (safety 0) (space 0))))) (funcall #'t a f fa)))))
    
      (defclass res (standard-class) ((%size-st :initform nil :accessor size-st)))
      (defclass d (standard-class) ((%size-n :initform nil :accessor size-n)))
      (defmethod sb-mop:validate-superclass ((class class) (meta standard-class)) defun t)
      (defmethod initialize-instance :after ((obj res) &key &allow-other-keys) (setf (size-st obj) (sb-vm::primitive-object-size (type-of (let ((a #xFFFF)) (declare (type (integer #x0 #xFFFF) a)))))))
      (defmethod initialize-instance :after ((obj d) &key) (setf (size-n obj) (sb-vm::primitive-object-size 0)))
      (defclass simd-virtual-guard (res d) ((%spn :initform 0 :accessor spn :type integer)) (:metaclass d))
    
      (let ((lac (make-instance 'simd-virtual-guard)) (data f) (b "8153024679"))
        `(declare (type (array (member ,(let* ((i '())) (do* ((y 0 (+ y 1))) ((= (- y 1) 9) 'nil) (push y i)))) (3)) data)
                  (type string b)
                  (type simd-virtual-duard lac))
    
        (setf (spn lac) (+ (size-st lac) (size-n lac)))
    
        (loop for ll from (- (sb-vm::primitive-object-size b) 55) downto 0 by 4
              do (progn
                   (setf (char b ll) #\0)
                   (setf (char b (- ll #x1)) #\1)
                   (setf (char b (if (= ll 1) (- (+ ll 9) #x2) (- ll #x2))) #\2)))
    
        (- (ash 1 2) (- (char-code (char b 0)) (sb-vm::primitive-object-size "2")))))
    
    (defun sbcl-vrt-simd64 (f0 f1 &aux (returnable 0) (declare (labels ((nil (f0 f1) (declare (type (function ()) f0) (type (function ()) f1)))) (funcall #'nil f0 f1))))
      (labels ((pntr (addr) (sb-sys:sap-ref-8 (sb-sys:int-sap addr) 0))
               (ref (obj) (sb-kernel:get-lisp-obj-address obj)))
    
        (macrolet ((s (v) `(setq returnable ,v)))
          (let ((d (- (ref f0) (ref f1))))
            (declare (type integer d))
    
            (if (not (ash (- (* (integer-length 0) (integer-length 0)) 1) d))
              (do* ((d d (- d 1))) (zerop d)
                (case (+ (ref f0) d)
                  (0XC3C9 (s 0))
                  (0XB8 (if (not (+ (ref f0) d 1)) (s 1) (s -1))
                  (0XC031 (s 2)))))))
    
          (return-from sbcl-vrt-simd64 returnable))))

    пародия на https://www.govnokod.ru/29120

    lisp-worst-code, 23 Июня 2025

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

    +1

    1. 1
    2. 2
    3. 3
    Хуже отсутствия документации может быть только документация
    написанная на отвали, с устаревшей информацией и проебом
    важных деталей, без которых говнокод не запустится даже с бубном.

    BelCodeMonkey, 09 Июня 2025

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

    +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
    if (!$_pwd_trusted && $resto && $has_image && BOARD_DIR === 'g' && strpos($_thread_sub, '/aicg/') !== false) {
            $_bot_headers = spam_filter_format_http_headers($com, $country, "$insfile$ext", $_threat_score, $_req_sig);
            log_spam_filter_trigger('block_aicg', BOARD_DIR, $resto, $host, 1, $_bot_headers);
            error(S_IPRANGE_BLOCKED_IMG . ' ' . S_IPRANGE_BLOCKED_TEMP . S_IPRANGE_BLOCKED_L1);
          }
          
          if (!$_pwd_trusted && $resto && $has_image && BOARD_DIR === 'vg' && strpos($_thread_com, '/lolg/') !== false) {
            $_bot_headers = spam_filter_format_http_headers($com, $country, "$insfile$ext", $_threat_score, $_req_sig);
            log_spam_filter_trigger('block_lolg', BOARD_DIR, $resto, $host, 1, $_bot_headers);
            error(S_IPRANGE_BLOCKED_IMG . ' ' . S_IPRANGE_BLOCKED_TEMP . S_IPRANGE_BLOCKED_L1);
            //show_post_successful_fake($resto);
            //return;
          }
          
          if (!$_pwd_trusted && $resto && $has_image && BOARD_DIR === 'vg' && strpos($_thread_com, '/overwatch') !== false) {
            $_bot_headers = spam_filter_format_http_headers($com, $country, "$insfile$ext", $_threat_score, $_req_sig);
            log_spam_filter_trigger('block_owg', BOARD_DIR, $resto, $host, 1, $_bot_headers);
            error(S_IPRANGE_BLOCKED_IMG . ' ' . S_IPRANGE_BLOCKED_TEMP . S_IPRANGE_BLOCKED_L1);
            //show_post_successful_fake($resto);
            //return;
          }
          
          if (false && !$_pwd_trusted && $resto && $has_image && BOARD_DIR === 'fa' && strpos($_thread_sub, 'Workwear General') !== false) {
            $_bot_headers = spam_filter_format_http_headers($com, $country, "$insfile$ext", $_threat_score, $_req_sig);
            log_spam_filter_trigger('block_denim', BOARD_DIR, $resto, $host, 1, $_bot_headers);
            error(S_IPRANGE_BLOCKED_IMG . ' ' . S_IPRANGE_BLOCKED_TEMP . S_IPRANGE_BLOCKED_L1);
            //show_post_successful_fake($resto);
            //return;
          }
          
          if (!$_pwd_known && $resto && $has_image && BOARD_DIR === 'vg' && strpos($_thread_sub, '/bag/') !== false && $browser_id === '04d2237a2') {
            $_bot_headers = spam_filter_format_http_headers($com, $country, "$insfile$ext", $_threat_score, $_req_sig);
            log_spam_filter_trigger('block_bag', BOARD_DIR, $resto, $host, 1, $_bot_headers);
            error(S_IPRANGE_BLOCKED_IMG . ' ' . S_IPRANGE_BLOCKED_TEMP . S_IPRANGE_BLOCKED_L1);
          }
          
          if (false && !$_pwd_known && !$resto && (BOARD_DIR === 'co' || BOARD_DIR === 'a') && $country !== 'XX' && $browser_id === '02b99990d' && ($country == 'GB' || $country == 'DE' || $country == 'AU' || strpos($_COOKIE['_tcs'], $_SERVER['HTTP_X_TIMEZONE']) === false)) {
            $_bot_headers = spam_filter_format_http_headers($com, $country, "$insfile$ext", $_threat_score, $_req_sig);
            log_spam_filter_trigger('block_peridot', BOARD_DIR, $resto, $host, 1, $_bot_headers);
            error(S_IPRANGE_BLOCKED_IMG . ' ' . S_IPRANGE_BLOCKED_TEMP . S_IPRANGE_BLOCKED_L1);
          }
          
          if (!$_pwd_trusted && $resto && $has_image && BOARD_DIR === 'vg' && strpos($_thread_sub, 'granblue') !== false) {
            $_bot_headers = spam_filter_format_http_headers($com, $country, "$insfile$ext", $_threat_score, $_req_sig);
            log_spam_filter_trigger('block_gbfg', BOARD_DIR, $resto, $host, 1, $_bot_headers);
            error(S_IPRANGE_BLOCKED_IMG . ' ' . S_IPRANGE_BLOCKED_TEMP . S_IPRANGE_BLOCKED_L1);
            //show_post_successful_fake($resto);
            //return;
          }
          
          if (!$_pwd_known && $resto && $has_image && BOARD_DIR === 'v' && strpos($_thread_sub, 'gamesdonequick') !== false && $_threat_score >= 0.09 && mt_rand(0, 9) >= 1) {
            $_bot_headers = spam_filter_format_http_headers($com, $country, "$insfile$ext", $_threat_score, $_req_sig);
            log_spam_filter_trigger('block_adgq', BOARD_DIR, $resto, $host, 1, $_bot_headers);
            show_post_successful_fake($resto);
            return;
          }
          
          if (!$_pwd_known && $resto && $has_image && BOARD_DIR === 'vg' && strpos($_thread_sub, '/zzz/') !== false && $_threat_score >= 0.09 && mt_rand(0, 9) >= 1) {
            $_bot_headers = spam_filter_format_http_headers($com, $country, "$insfile$ext", $_threat_score, $_req_sig);
            log_spam_filter_trigger('block_zzz', BOARD_DIR, $resto, $host, 1, $_bot_headers);
            show_post_successful_fake($resto);
            return;
          }
          
          if (!$_pwd_verified && $resto && $has_image && BOARD_DIR === 'vg' && strpos($_thread_sub, '/funkg/') !== false && $_threat_score >= 0.09) {
            $_bot_headers = spam_filter_format_http_headers($com, $country, "$insfile$ext", $_threat_score, $_req_sig);
            log_spam_filter_trigger('block_funkg', BOARD_DIR, $resto, $host, 1, $_bot_headers);
            show_post_successful_fake($resto);
            return;
          }

    4chan.org. Хардкод бан. Продолжение https://govnokod.ru/29122.

    Админы, берите на заметку на свои форумы.

    trusted, known это проверки на число постов, связанных с куки+айпи.

    lemur, 22 Апреля 2025

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