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

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

    +5

    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
    #include <stdio.h>
    #define UPP 300
    float conversion(float fahr);
    
    main(){
    	float far;
    	int a;
    	a = UPP;
    	for(far = 0; far <= a; ++++++++++++++++++++++++++++++++++++++++far)
    		printf("%.f\t%.1f\n", far, conversion(far));
    }
    
    float conversion(float cels){
    	float c;
    	c = ((5*(cels-32))/(9));
    	return c;
    }

    how do I make it 20 by 20 in a shorter way, without having to put 20 times "++" please

    https://www.reddit.com/r/C_Programming/comments/ff5zph/how_do_i_make_it_20_by_20_in_a_shorter_w ay/

    eukaryote, 08 Марта 2020

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

    +5

    1. 1
    2. 2
    3. 3
    4. 4
    БОЖЕСТВЕННЫЙ СУДЪ
    МАТУШКА ЛИЧНОЕ ИМЯ РОДА В ЧЕСТИ ИНГА
    ЗАПРЕЩЕНО НАРУШАТЬ КОН СВОБОДНОЙ ВОЛИ
    УТВЕРЖДЕНО

    Пост для обсуждания, разработки и каталогизации живых доброй души коберодных вореций.

    Срать тут:

    gost, 15 Февраля 2020

    Комментарии (627)
  4. Pascal / Говнокод #26436

    +5

    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
    begin
                     G4.Caption:='X';
                     if G5.Caption='' then
                     begin
                       G5.Caption:='X';
                       if G6.Caption='' then
                       begin
                         G6.Caption:='X';
                         if G7.Caption='' then
                         begin
                           G7.Caption:='X';
                           if G8.Caption='' then G8.Caption:='X' else
                           if sg8=1 then
                              G8.Font.Style:=[fsBold,fsStrikeOut];
                         end else
                         if sg7=1 then
                            G7.Font.Style:=[fsBold,fsStrikeOut];
                       end else
                       if sg6=1 then
                          G6.Font.Style:=[fsBold,fsStrikeOut];
                     end else
                     if sg5=1 then
                        G5.Font.Style:=[fsBold,fsStrikeOut];
                   end else
                   if sg4=1 then
                      G4.Font.Style:=[fsBold,fsStrikeOut];
                 end else
                 if sg3=1 then
                    G3.Font.Style:=[fsBold,fsStrikeOut];
               end else
               if sg2=1 then
                  G2.Font.Style:=[fsBold,fsStrikeOut];
               if H2.Caption='' then H2.Caption:='X' else
               if sh2=1 then H2.Font.Style:=[fsBold,fsStrikeOut];
               if F2.Caption='' then
               begin
                 F2.Caption:='X';
                 if E3.Caption='' then
                 begin
                   E3.Caption:='X';
                   if D4.Caption='' then
                   begin
                     D4.Caption:='X';
                     if C5.Caption='' then
                     begin
                       C5.Caption:='X';
                       if B6.Caption='' then
                       begin
                         B6.Caption:='X';
                         if A7.Caption='' then A7.Caption:='X' else
                         if sa7=1 then
                         A7.Font.Style:=[fsBold,fsStrikeOut];
                       end else
                       if sb6=1 then
                       B6.Font.Style:=[fsBold,fsStrikeOut];
                     end else
                     if sc5=1 then
                     C5.Font.Style:=[fsBold,fsStrikeOut];
                   end else
                   if sd4=1 then
                   D4.Font.Style:=[fsBold,fsStrikeOut];
                 end else
                 if se3=1 then
                 E3.Font.Style:=[fsBold,fsStrikeOut];
               end else
               if sf2=1 then
               F2.Font.Style:=[fsBold,fsStrikeOut];
             end;
          6: begin //Король
        {E1}   if ((se1=1) and not ((E1.Caption<>'Ферзь') or (E1.Caption<>'Ладья') or (E1.Caption<>'Король')) or
        {D1}   ((sd1=1) and not ((E1.Caption='') and ((D1.Caption='Ферзь') or (D1.Caption='Ладья')))) or
        {C1}   ((sc1=1) and not (((E1.Caption='') and (D1.Caption='')) and ((C1.Caption='Ферзь') or (C1.Caption='Ладья')))) or
        {B1}   ((sb1=1) and not (((E1.Caption='') and (D1.Caption='') and (C1.Caption='')) and ((B1.Caption='Ферзь') or (B1.Caption='Ладья')))) or
        {A1}   ((sa1=1) and not (((E1.Caption='') and (D1.Caption='') and (C1.Caption='') and (B1.Caption='')) and ((A1.Caption='Ферзь') or (A1.Caption='Ладья')))) or
        {E2}   ((se2=1) and not ((E2.Caption='Слон') or (E2.Caption='Ферзь') or (E2.Caption='Пешка') or (E2.Caption='Король'))) or
        //ПРОДОВЖИТИ
        {D3}   ((sd3=1) and not ((E2.Caption='') and ((D3.Caption='Ферзь') or (D3.Caption='Слон')))) or
        {C4}   ((sc4=1) and not (((E2.Caption='') and (D3.Caption='')) and ((C4.Caption='Ферзь') or (C4.Caption='Слон')))) or
        {B5}   ((sb5=1) and not (((E2.Caption='') and (D3.Caption='') and (C4.Caption='')) and ((B5.Caption='Ферзь') or (B5.Caption='Слон')))) or
        {A6}   ((sa6=1) and not (((E2.Caption='') and (D3.Caption='') and (C4.Caption='') and (B5.Caption='')) and ((A6.Caption='Ферзь') or (A6.Caption='Ладья')))) or
        {F2}   ((sf2=1) and not (E2.Caption='Ладья') or (E2.Caption='Ферзь')) or
        {F3}   ((sf3=1) and not ((F2.Caption='') and ((F3.Caption='Ферзь') or (F3.Caption='Ладья')))) or
        {F4}   ((sf4=1) and not (((F2.Caption='') and (F3.Caption='')) and ((F4.Caption='Ферзь') or (F4.Caption='Ладья')))) or
        {F5}   ((sf5=1) and not (((F2.Caption='') and (F3.Caption='') and (F4.Caption='')) and ((F5.Caption='Ферзь') or (F5.Caption='Ладья')))) or
        {F6}   ((sf6=1) and not (((F2.Caption='') and (F3.Caption='') and (F4.Caption='') and (F5.Caption='')) and ((F6.Caption='Ферзь') or (F6.Caption='Ладья')))) or
        {F7}   ((sf7=1) and not (((F2.Caption='') and (F3.Caption='') and (F4.Caption='') and (F5.Caption='') and (F6.Caption='')) and ((F7.Caption='Ферзь') or (F7.Caption='Ладья')))) or
        {F8}   ((sf8=1) and not (((F2.Caption='') and (F3.Caption='') and (F4.Caption='') and (F5.Caption='') and (F6.Caption='') and (F7.Caption='')) and ((F8.Caption='Ферзь') or (F8.Caption='Ладья')))) or
        {G2}   ((sg2=1) and not (G2.Caption='Ферзь') or (G2.Caption='Слон')) or
        {H3}   ((sh3=1) and not ((G2.Caption='') and ((H3.Caption='Ферзь') or (H3.Caption='Слон')))) or
        {H1}   ((sh1=1) and not (H1.Caption'Ферзь') or (H1.Caption='Слон')) or
       {Кони}  ((sh2=1) and not (H2.Caption='Конь')) or ((sg3=1) and not (G3.Caption='Конь')) or  ((se3=1) and not (E3.Caption='Конь')) or  ((sd2=1) and not(D2.Caption='Конь'))
               ) then if (F1.Caption='') then F1.Caption:='X' else
               if sf1=1 then F1.Font.Style:=[fsBold,fsStrikeOut];
             end;

    Как-то на первом или втором курсе недоунивера возникло желание сделать шахматы в ООП на Паскале. Решил закодить 64 кнопки (8*8 поле). Сделал переменные для идентификации хода черных/белых, для 2 режимов, в первом из которых кликаешь на свою фигуру (надпись на кнопке) и тебе показывают доступные ходы ею (Х куда можно поставить фигуру, подчеркнутое название вражеской фигуры при возможность её забрать). Ты кликаешь, поле очищается от подсказок, фигура перемещается, проверка на шах/мат (ад), ход передается другому цвету фигур (Жирное начертание для определения) и режим взаимодействия с игровым полем опять переходит в выбор фигуры. Теоретически закодировав каждую кнопку на все возможные события шахматы были бы закончены полностью. Вот только спустя окончания кодировки первой кнопки я заYAYлся и забросил ибо говнокод вышел в 1000 строк на одну YAYдь кнопку. Разумеется, показать могу лишь часть

    Zick, 12 Февраля 2020

    Комментарии (38)
  5. PHP / Говнокод #26425

    +5

    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
    function fix_hacker_strings($str){
            $s=$str;
            $s=str_replace('/*', 'xx', $s);
            $s=str_replace('*/', 'xx', $s);
            $s=str_replace('../', 'xxx', $s);
            $s=str_replace('..\\', 'xxx', $s);
            $s=str_ireplace('file:', 'xxxxx', $s);
            $s=str_ireplace(':$', 'xx', $s);
            $s=str_ireplace('http:', 'xxxx', $s);
            $s=str_ireplace('https:', 'xxxxx', $s);
            $s=str_ireplace('script', 'xxxxxx', $s);
            $s=str_ireplace('delete', 'xxxxxx', $s);
            $s=str_ireplace('drop', 'xxxx', $s);
            $s=str_ireplace('select', 'xxxxxx', $s);
            $s=str_ireplace('update', 'xxxxxx', $s);
            $s=str_ireplace('replace', 'xxxxxxx', $s);
            $s=str_ireplace('/etc/', '/xxx/', $s);
            $s=str_ireplace('/var/', '/xxx/', $s);
            $s=str_ireplace('/root/', '/xxxx/', $s);
            $s=str_ireplace('/bin/', '/xxx/', $s);
            $s=str_ireplace('/usr/', '/xxx/', $s);
            $s=str_ireplace('/sys/', '/xxx/', $s);
            $s=str_ireplace('/sbin/', '/xxxx/', $s);        
            $s=str_ireplace('/proc/', '/xxxx/', $s);
            $s=str_ireplace('/boot/', '/xxxx/', $s);
            $s=str_ireplace('mysql', 'xxxxx', $s); 
            return $s;
    }

    обработка user input

    dim1r, 08 Февраля 2020

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

    +5

    1. 1
    Воцарилась над вами, проверьте.

    Jll-O6OBb, 26 Декабря 2019

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

    +5

    1. 1
    2. 2
    Скоро Новый год. Високосный год Крысы.
    А ты уже загадал желание? ^_

    https://www.youtube.com/watch?v=RpDfkJD4PYU

    Wyrap_nJll-oM_qpaupu, 24 Декабря 2019

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

    +5

    1. 1
    2. 2
    // в строке поменять тире на пробелы
    $city_alias = implode(' ', explode('-', $readable_city_alias));

    supaweb, 10 Сентября 2019

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

    +5

    1. 1
    2. 2
    3. 3
    4. 4
    public class clsActMarriage
    {
       ...
    }

    Трудности перевода из серии "Ясные печеньки".

    Как вам название сущности? Буквально "Акт женитьбы".
    Оглянулся на 300+ строк вокруг и понял что это на самом деле "Акт брака" в контексте товара.
    Класс занимается созданием и наполнением документа о наличии брака по утвержденной форме.

    Ну кто так называет? Откуда это: лень, глупость или неграмотность? Как это пропустили на ревью?
    Почему не "FlawReport" не "DefectBulletin" или
    на худой конец "DocumentOfUnquality" если по инглишу в школе неуд был.
    Кто-то в прошлом сэкономил 1 минуту, а в настоящем это обернулось потерей 20 минут на раскуривание.
    Плохие имена переменных которые нельзя изменить - боль кровавого энтерпрайза.

    Ух, пичот! (╯°□°)╯︵┻━┻

    Gilbert, 23 Августа 2019

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

    +5

    1. 1
    2. 2
    3. 3
    #vCardRoom > div.v-card__text > div > div > form > div > div.flex.xs12 > div > div > div.v-text-field__details > div > div > div {
        font-size: 16px;
    }

    anuxa, 07 Мая 2019

    Комментарии (37)
  11. Си / Говнокод #25456

    +5

    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
    /*
    https://habr.com/ru/company/jugru/blog/444212/
    
    Александр: Я не думаю, что существует какое-то одно «правильное» определение ФП,
    но если говорить лично обо мне, то ФП — это нечто с функциональной композицией и
    функциями первого класса.
    
    Иван: Я согласен, но добавил бы ещё функции высшего порядка — те, которые могут
    принимать другие функции в качестве аргументов и возвращать как результат.
    
    Cергей: Ссылка на функцию в Си — считается?
    
    Иван: Нет, Си не является функциональным языком программирования :-)
    
    Сергей: Расскажи, почему?
    
    Иван: Потому что нельзя из комбинации указателей на функции создать новую функцию,
    можно только указывать на уже существующие. Конечно, если в ход не пошли какие-то
    ассемблерные хаки.
    */
    
    
    #include <stdio.h>
    #include <inttypes.h>
    #include <stddef.h>
    #include <stdlib.h>
    #include <errno.h>
    
    #define FUNC(a, ...) typeof( a (*) (__VA_ARGS__) )
    
    uint64_t mul2(uint64_t a)
    {
      return a*2;
    }
    
    uint64_t add2(uint64_t a)
    {
      return a+2;
    }
    
    uint64_t chaincaller(uint64_t a, typeof(uint64_t (*)(uint64_t)) *chain)
    {
      while(*chain != NULL)
      {
        a = (*chain)(a);
        chain++;
      }
      return a;
    }
    
    FUNC(uint64_t, uint64_t) *combine_fn (FUNC(uint64_t, uint64_t) a, FUNC(uint64_t, uint64_t) b)
    {
      FUNC(uint64_t, uint64_t) *funchain = (FUNC(uint64_t, uint64_t) *)malloc(sizeof( FUNC(uint64_t, uint64_t) [3]) );
      if (funchain == NULL)
      {
        exit(ENOMEM);
      }
      funchain[0] = a;
      funchain[1] = b;
      funchain[2] = NULL;
      return funchain;
    }
    
    
    int main(void)
    {
      FUNC(uint64_t, uint64_t) *func_chain = combine_fn(mul2,add2);
      uint64_t a = 15;
      uint64_t b = chaincaller(a, func_chain);
      printf("%" PRIu64 " * 2 + 2 = %" PRIu64 "\n", a,b);
      free(func_chain);
      return 0;
    }

    Ассемблерные хуяки.
    https://wandbox.org/permlink/gdRggB77GQOiNzyJ
    Он так говорит, будто б в крестоговно впилили какой-то недоJIT, который честно может сгенерить одну функцию из двух.

    j123123, 19 Марта 2019

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