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

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

    +55.3

    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
    #include<iostream>
    #include<math.h>
    //#include<csdio>
    using namespace std;
    
    void main(){
         //char*s1=new char[0]
              int i=0;
         do
              char*s1=new char[0]; 
              cout<<'write s1: ';
              cin>>s1[i];
              i=i+1;
         while (*s1[i]=="\0");  
         for(int j=1, j==i, j++)  
              cout<<s1[j];
              cout<<endl;
              delete []s1;
    }

    Вот такую поделку мне прислали на проверку с жалобой "не работает".

    uncle Lem, 06 Января 2010

    Комментарии (36)
  3. Си / Говнокод #1274

    +122.4

    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
    /* sent by Stephan Hughson - 2003 */
    /* must be compiled with cc or g++*/
    
    #include <stdio.h>
    
    int main(int t,int _,char*a)
    {return!0<t?t<3?main(-79,-13,a+main(-87,1-_,
    main(-86, 0, a+1 )+a)):1,t<_?main(t+1, _, a ):3,main ( -94, -27+t, a
    )&&t == 2 ?_<13 ?main ( 2, _+1, "%s %d %d\n" ):9:16:t<0?t<-72?main(_,
    t,"@n'+,#'/*{}w+/w#cdnr/+,{}r/*de}+,/*{*+,/w{%+,/w#q#n+,/#{l,+,/n{n+\
    ,/+#n+,/#;#q#n+,/+k#;*+,/'r :'d*'3,}{w+K w'K:'+}e#';dq#'l q#'+d'K#!/\
    +k#;q#'r}eKK#}w'r}eKK{nl]'/#;#q#n'){)#}w'){){nl]'/+#n';d}rw' i;# ){n\
    l]!/n{n#'; r{#w'r nc{nl]'/#{l,+'K {rw' iK{;[{nl]'/w#q#\
    n'wk nw' iwk{KK{nl]!/w{%'l##w#' i; :{nl]'/*{q#'ld;r'}{nlwb!/*de}'c \
    ;;{nl'-{}rw]'/+,}##'*}#nc,',#nw]'/+kd'+e}+;\
    #'rdq#w! nr'/ ') }+}{rl#'{n' ')# }'+}##(!!/")
    :t<-50?_==*a ?putchar(a[31]):main(-65,_,a+1):main((*a == '/')+t,_,a\
    +1 ):0<t?main ( 2, 2 , "%s"):*a=='/'||main(0,main(-61,*a, "!ek;dc \
    i@bK'(q)-[w]*%n+r3#l,{}:\nuwloca-O;m .vpbks,fxntdCeghiry"),a+1);}

    Вот результат работы программы(всё не вместилось):
    On the first day of Christmas my true love gave to me
    a partridge in a pear tree.

    On the second day of Christmas my true love gave to me
    two turtle doves
    and a partridge in a pear tree.

    ...

    On the eighth day of Christmas my true love gave to me
    eight maids a-milking, seven swans a-swimming,
    six geese a-laying, five gold rings;
    four calling birds, three french hens, two turtle doves
    and a partridge in a pear tree.

    On the ninth day of Christmas my true love gave to me
    nine ladies dancing, eight maids a-milking, seven swans a-swimming,
    six geese a-laying, five gold rings;
    four calling birds, three french hens, two turtle doves
    and a partridge in a pear tree.

    On the tenth day of Christmas my true love gave to me
    ten lords a-leaping,
    nine ladies dancing, eight maids a-milking, seven swans a-swimming,
    six geese a-laying, five gold rings;
    four calling birds, three french hens, two turtle doves
    and a partridge in a pear tree.

    On the eleventh day of Christmas my true love gave to me
    eleven pipers piping, ten lords a-leaping,
    nine ladies dancing, eight maids a-milking, seven swans a-swimming,
    six geese a-laying, five gold rings;
    four calling birds, three french hens, two turtle doves
    and a partridge in a pear tree.

    On the twelfth day of Christmas my true love gave to me
    twelve drummers drumming, eleven pipers piping, ten lords a-leaping,
    nine ladies dancing, eight maids a-milking, seven swans a-swimming,
    six geese a-laying, five gold rings;
    four calling birds, three french hens, two turtle doves
    and a partridge in a pear tree.

    guest, 28 Июня 2009

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

    +27

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    $res["LIST_PAGE_URL"] = str_replace("//", "/", str_replace("#LANG#", $res["LANG_DIR"],
    							str_replace("#SITE_DIR#", SITE_DIR,
    								str_replace("#SERVER_NAME#", SITE_SERVER_NAME,
    									str_replace("#IBLOCK_ID#", $res["IBLOCK_ID"], $res["LIST_PAGE_URL"])
    								)
    							)
    						)
    					);

    битрикс

    guest, 23 Ноября 2008

    Комментарии (36)
  5. Java / Говнокод #28658

    +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
    Statement stmt1 = null;
            ResultSet rs1 = null;
         
            try {
                StringBuilder sb = new StringBuilder(2000);
                String sql = "";
                String ss = "";
                String ss_begin = "";
                String ss_middle = "";
                String ss_end = "";
                int xcount = 0;
                String XXX_ID = "";
                String XXX_NAME = "";
    
    
                if (c.XLANG_ID == 1) {
                    sql = sql + " SELECT  99 , 'Исходные'  FROM dual union all ";
                    sql = sql + " SELECT  1 , 'Непарные исходные'  FROM dual union all ";
                    sql = sql + " SELECT  2 , 'Временная'            FROM dual union all ";
                    sql = sql + " SELECT  3 , 'Встречные'         FROM dual ";
                    //sql = sql +  " SELECT  4 , 'Непарные встречные'         FROM dual ";
                } else if (c.XLANG_ID == 2) {
                    sql = sql + " SELECT  99 , 'Base BPEBs' FROM dual union all ";
                    sql = sql + " SELECT  1 , 'Base BPEBs unpaired' FROM dual union all ";
                    sql = sql + " SELECT  2 , 'Temporary BPEB' FROM dual union all ";
                    sql = sql + " SELECT  3 , 'Generated BPEBs' FROM dual ";
                    //sql = sql +  " SELECT  4 , 'Generated BPEBs unpaired' FROM dual ";
                }
    
                stmt1 = this.con.createStatement();
                rs1 = stmt1.executeQuery(sql);
    
                while (rs1.next()) {
                    xcount = xcount + 1;
                    XXX_ID = rs1.getString(1);
                    XXX_NAME = rs1.getString(2);
    
                    sb = sb.append("<msg>")
                            .append("<xid>").append(XXX_ID).append("</xid>")
                            .append("<xname>").append(vtb.budget.osa.tools.Tools.stringToXML(XXX_NAME)).append("</xname>")
    
                            .append("</msg>");
                }
                rs1.close();
                stmt1.close();
    
                ss_begin = ss_begin + "<xml id='XML_table1'>"
                        + "<tab1>";
    
                ss_end = ss_end
                        + "</tab1>"
                        + "</xml>";
    
                if (xcount == 0) {
                    ss_middle = ss_middle + "<msg>"
                            + "<xid></xid>"
                            + "<xcode></xcode>"
                            + "<xname></xname>"
                            + "</msg>";
                } else {
                    ss_middle = sb.toString();
                }
    
    
                ss = ss_begin + ss_middle + ss_end;
    
                ss_begin = null;
                ss_middle = null;
                ss_end = null;
                sb = null;
    
    
                return ss;
    
            }

    yamert89, 04 Апреля 2023

    Комментарии (35)
  6. Haskell / Говнокод #28539

    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
    #!/usr/bin/guile -s
    !#
    
    (define (pt n s)
      (cond ((< n 1) 0)
            ((= n 1) 1)
            ((= s 0) 0)
            ((= s 1) 1)
            ((= s n) 1)
            ((> s n) 0)
            (else (+ (pt (- n 1) s) (pt (- n 1) (- s 1))))))
    
    (display (pt 1 1)) ;; 1
    (newline)
    
    (display (pt 3 2)) ;; 2
    (newline)
    
    (display (pt 5 3)) ;; 6
    (newline)

    Лисп-загадка: угадайте, что делает этот (вышеприведённый) код.

    JloJle4Ka, 05 Января 2023

    Комментарии (35)
  7. bash / Говнокод #28235

    0

    1. 1
    2. 2
    3. 3
    #!/bin/sh
    
    [ ${SHELL} = "/bin/bash" ] || exit "Bash required!"

    Stallman, 24 Июня 2022

    Комментарии (35)
  8. Си / Говнокод #27973

    +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
    // тред лоулевел-хаков #1
    
    #include <stdio.h>
    #include <stdlib.h>
    
    void hello(void)
    {
            puts("Hello!");
    }
    
    void goodbye(void)
    {
            puts("Goodbye!");
    }
    
    void set_sp_(void *p)
    {
            void *s[0];
            s[0] = p;
    }
    
    void set_sp(void *p)
    {
            set_sp_((void*)p);
    }
    
    int main(void)
    {
            void *new_stack[1024] = {
                    [1019] = (void*)0,
                    [1020] = (void*)&hello,
                    [1021] = (void*)&goodbye,
                    [1022] = (void*)&exit
            };
            set_sp((void*)&new_stack[1019]);
            return 0;
    }

    UB-ы, платформенно зависимый кот, битовая магия

    всё сюда
    |
    |
    \/

    Hu3KoypoBHeBblunemyx, 28 Января 2022

    Комментарии (35)
  9. bash / Говнокод #27560

    +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
    #!/bin/bash
    set -euo pipefail
    
    host() {
        echo "n${1}.local"
    }
    
    node() {
        echo "erl@$(host $1)"
    }
    
    build() {
        [ "${1}" -eq "1" ] && echo "build: ."
    }
    
    container() {
        cat <<EOF
      worker${1}:
        $(build $1)
        image: worker
        hostname: $(host $1)
        networks:
          backplane:
            aliases:
              - $(host $1)
    
        environment:
        - "NODE_NAME=$(node $1)"
        - ... прочая питушня
    EOF
    }
    
    main() {
        cat <<EOF
    version: '3.3'
    
    networks:
      backplane:
    
    services:
    $(node 1)
    
    $(node 2)
    
    ...
    EOF
    }
    
    main > docker-compose.yml
    docker-compose $@

    Как тебе такое, Helm?

    CHayT, 13 Августа 2021

    Комментарии (35)
  10. Си / Говнокод #27420

    +2

    1. 001
    2. 002
    3. 003
    4. 004
    5. 005
    6. 006
    7. 007
    8. 008
    9. 009
    10. 010
    11. 011
    12. 012
    13. 013
    14. 014
    15. 015
    16. 016
    17. 017
    18. 018
    19. 019
    20. 020
    21. 021
    22. 022
    23. 023
    24. 024
    25. 025
    26. 026
    27. 027
    28. 028
    29. 029
    30. 030
    31. 031
    32. 032
    33. 033
    34. 034
    35. 035
    36. 036
    37. 037
    38. 038
    39. 039
    40. 040
    41. 041
    42. 042
    43. 043
    44. 044
    45. 045
    46. 046
    47. 047
    48. 048
    49. 049
    50. 050
    51. 051
    52. 052
    53. 053
    54. 054
    55. 055
    56. 056
    57. 057
    58. 058
    59. 059
    60. 060
    61. 061
    62. 062
    63. 063
    64. 064
    65. 065
    66. 066
    67. 067
    68. 068
    69. 069
    70. 070
    71. 071
    72. 072
    73. 073
    74. 074
    75. 075
    76. 076
    77. 077
    78. 078
    79. 079
    80. 080
    81. 081
    82. 082
    83. 083
    84. 084
    85. 085
    86. 086
    87. 087
    88. 088
    89. 089
    90. 090
    91. 091
    92. 092
    93. 093
    94. 094
    95. 095
    96. 096
    97. 097
    98. 098
    99. 099
    100. 100
    #include <stdio.h>
    #include <stdlib.h>
    #define RW(a, c) for(src = (a);src < (c); src++, dst++){*dst=*src;} 
    void *pairscan(char *p)
    {
      size_t p_count = 1;
      do {
        if(*p == 'P') {
          p_count++;
        }
        else {
          p_count--;
        }
        p++;
      } while(p_count != 0);
      return p;
    }
    
    
    void rewrite(char *src, char *dst)
    {
      int p_r = 0;
      while(*src == 'P') {
        *dst = *src;
        src++; dst++;
        if (p_r < 3)
        {
          p_r++;
        }
      }
      if(*src == 'I') {
        if(p_r < 1) {
          while(*src != 0) {
            *dst = *src;
            src++; dst++;
          }
          *dst = 0;
          return;
        }
        dst--;
        src++;
        //src = pairscan(src+1);
        while(*src != 0) {
          *dst = *src;
          src++; dst++;
        }
        *dst = 0;
        return;
      }
      if(*src == 'K') {
        if(p_r < 2)
        {
          while(*src != 0) {
            *dst = *src;
            src++; dst++;
          }
          *dst = 0;
          return;
        }
        dst-=2;
        char *exp1 = pairscan(src+1);
        char *exp2 = pairscan(exp1);
        RW(src+1,exp1);
        for(; src < exp2; src++){}
        while(*src != 0) {
          *dst = *src;
          src++; dst++;
        }
        *dst = 0;
        return;
      }
      if(*src == 'S') {
        if(p_r < 3) {
          while(*src != 0){
            *dst = *src;
            src++; dst++;
          }
          *dst = 0;
          return;
        }
        dst-=1;
        char *exp1 = pairscan(src+1);
        char *exp2 = pairscan(exp1);
        char *exp3 = pairscan(exp2);
        RW(src+1,exp1);
        RW(exp2,exp3);    
        *dst = 'P';
        dst++;
        RW(exp1,exp2);
        RW(exp2,exp3);
        while(*src != 0) {
          *dst = *src;
          src++; dst++;
        }
        *dst = 0;
        return;
      }
      *dst = 0;
      return;
    }

    Кобенаторная логика
    SKI combinator calculus

    j123123, 11 Мая 2021

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

    +1

    1. 1
    С днём математика вас, питухи!

    OCETuHCKuu_nemyx, 01 Апреля 2021

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