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

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

    +136

    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
    printf("Enter item code: ");                                        //Prompts user
    scanf ("%14s", codenew1);                                           //Read user input
    len = strlen(codenew1);                                             //Read each character into variable len
    
    while (len != strspn(codenew1, "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"))
    {
        printf ("Name contains non-alphabet characters. Try again!: "); //Prompts user to try again
        scanf ("%14s", codenew1);                                       //Reads user input
        len = strlen(codenew1);                                         //Read each character into variable len
    }                                                                   //Endwhile
    strncpy(codenew, codenew1,2);                                       //Copy the first two characters from the variable codenew1
    codenew[2] = 0;                                                     //Store first two characters into variavle codenew
    
    for ( j = 0; j < num_items; j++)                                    //Loop for num_items times
    {                                                                   //Beginning of for loop
        if (strcmp(array[j].code1, codenew) == 0)                       //If codenew is found in file
        {                                                               //Beginning of if statement
            price[i] = item_qty[i] * array[j].price1;                   //Calculating the price of an item
            printf("Price : %d", price[i]);                             //Prints price
            printf("\nEnter '%s' to confirm: ", array[j].itemname1);    //Confirming the item
            scanf("%19s", item_name1[i]);
            while (strcmp(item_name1[i], array[j].itemname1 )!=0)       //Looping until both item names are the same
            {                                                           //Begin while loop
                printf("Item name is not %s ,Try Again!: ", array[j].itemname1);    //Prompt user to try again
                scanf ("%19s", item_name1[i]);                              //Reads item name into an array
                len = strlen(item_name1[i]);                                //Reads each character into variable len
            }                                                               //End while loop
            len = strlen(item_name1[i]);                                    //Read each character into variable len
            while (len != strspn(item_name1[i], "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"))    //While len contains non alphabetic characters
            {                                                                       //Beginning while
                printf ("Name contains non-alphabet characters. Try again!: ");     //Prompts user to try again
                scanf ("%19s", item_name1[i]);                                      //Read user input
                len = strlen(item_name1[i]);                                        //Read each character into variable len
            }                                                                       //End while
            strncpy(item_name[i], item_name1[i], 20);                               //Copy the first two characters from the variable codenew1
            item_name[i][20] = 0;                                                   //Store first 20 characters in variable item_name[i]
            total_price+= price[i];                                     //Calculate total price
            break;                                                      //Terminates loop
        }                                                               //End of if statement
        else 
            if (strcmp(array[j].code1, codenew) != 0)                       //If codenew is found in file
            {
                printf("Invalid input! Try again.");
                goto Here;
            }
    }                                                           //End of for loop

    Бесценные комментарии!
    http://stackoverflow.com/questions/29045067/error-check-files

    myaut, 14 Марта 2015

    Комментарии (34)
  3. 1C / Говнокод #17700

    −119

    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
    функция КрасиваяДата ( Дата ) 
    	
    	Стр = "";
    	
    	Д = День (Дата);
    	М = Месяц (Дата);
    	Г = Год (Дата);
    	
    	Если      М = 1 тогда 
    		мес = "января";
    	ИначеЕсли М = 2 тогда 
    		мес = "февраля";
    	ИначеЕсли М = 3 Тогда 
    		мес = "марта";
    	ИначеЕсли М = 4 Тогда
    		мес = "апреля";
    	ИначеЕсли М = 5 Тогда 
    		мес = "майя";
    	ИначеЕсли М = 6 Тогда 
    		мес = "июня";
    	ИначеЕсли М = 7 Тогда 
    		мес = "июля";
    	ИначеЕсли М = 8 Тогда 
    		мес = "августа" ;
    	ИначеЕсли М = 9 Тогда 
    		мес = "сентебря";
    	ИначеЕсли М = 10 Тогда 
    		мес = "октебря";
    	ИначеЕсли М =11 Тогда 
    		мес = "ноября";
    	ИначеЕсли М =12 Тогда 
    		мес = "декобря";
    	КонецЕсли;
    	
    	КДата = Строка (Д) + " " + мес + " " + Строка(Г) + " г.";
    	
    	Возврат КДата; 
    	
    КонецФункции

    Встретил сегодня такую конструкцию в отчете. Орфография передана без изменения

    spamersd, 26 Февраля 2015

    Комментарии (34)
  4. Assembler / Говнокод #17545

    +114

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    CFG ; start: scasb
    DCG ; salc
    AEEAFF ; and al,'\'-'/'
    AAEAFO ; add al,'/'
    DBFAFB ; int 29h
    DFDDGG ; jmp start

    Генератор лабиринта на Wct.

    Mihip, 29 Января 2015

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

    +59

    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
    #include <stdio.h>
    #include <stdlib.h>
    
    int main()
    {
        FILE *fp;
        char hc1,hc2,mc1,mc2;
        int hi1,hi2,mi1,mi2,hour,minute;
        system("echo %time% >time.txt");
        fp=fopen("time.txt","r");
        if(fp==NULL)
           exit(1) ;
        hc1=fgetc(fp);
        hc2=fgetc(fp);
        fgetc(fp);
        mc1=fgetc(fp);
        mc2=fgetc(fp);
        fclose(fp);
        remove("time.txt");
        hi1=hc1;
        hi2=hc2;
        mi1=mc1;
        mi2=mc2;
        hi1-=48;
        hi2-=48;
        mi1-=48;
        mi2-=48;
        hour=hi1*10+hi2;
        minute=mi1*10+mi2;
        printf("Current time is %d:%d\n",hour,minute);
        return 0;
    }

    Как узнать текущее время особо извращенным образом. http://stackoverflow.com/questions/5141960/get-the-current-time-in-c

    ales-hon-ne, 24 Декабря 2014

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

    +55

    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
    On Wed, 29 Oct 2014 20:29:33 +0000
    via Digitalmars-d <[email protected]> wrote:
    
    > On Wednesday, 29 October 2014 at 20:13:34 UTC, ketmar via 
    > Digitalmars-d wrote:
    > > On Wed, 29 Oct 2014 13:07:38 -0700
    > > Walter Bright via Digitalmars-d <[email protected]> 
    > > wrote:
    > >
    > >> There are still two string types, something you can't quite 
    > >> escape dealing with.
    > > and D has three string types. it's even better than C++!
    > 
    > Only three? C++ has seven:
    > 
    > 1. const char*  /* zero terminated single byte*/
    > 2. const char*  /* zero terminated multi byte */
    > 3. const wchar_t*  /* zero terminated wide */
    > 4. std::string	
    > 5. std::wstring
    > 6. std::u16string
    > 7. std::u32string
    ah, D has those 'char*' family too, but i don't count them as string
    types. ok, C++ wins. again. ;-)

    Хоть и не код, но смешно.
    Источник: http://forum.dlang.org/thread/[email protected]?page=3

    rst256, 18 Ноября 2014

    Комментарии (34)
  7. JavaScript / Говнокод #17116

    +166

    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
    function chekemailandpas(e) {
      var email1val = $('#email1').val();
      var pas1val = $('#password1').val();
      var name1val = $('#name1').val();
      var famil2val = $('#famil2').val();
      name1val = del_spaces(name1val);
      famil2val = del_spaces(famil2val);
      email1val = del_spaces(email1val);
      pas1val = del_spaces(pas1val);
      email1 = email1val.length;
      pas1 = pas1val.length;
      if(!e) {
       e = event || window.event; 
      }
      if(e == '[object MouseEvent]' || e.keyCode == 13 && email1val !== '' &&  pas1val !== '') {
        if(email1 < 5) {
          setTimeout(function() {
            $('#email1').css('background', 'rgba(240,128,128, 0.1)');
            setTimeout(function() {
              $('#email1').css('background', 'rgba(240,128,128,0.2)');
              setTimeout(function() {
                $('#email1').css('background', 'rgba(240,128,128,0.3)');
                setTimeout(function() {
                  $('#email1').css('background', 'rgba(240,128,128,0.4)');
                  setTimeout(function() {
                    $('#email1').css('background', 'rgba(240,128,128,0.5)');
                  }, 50);
                }, 50);
              }, 50);
            }, 50);
          }, 500);
          if($('#email1').css('background', 'rgba(240,128,128,0.5)')) {
            setTimeout(function() {
              $('#email1').css('background', 'rgba(240,128,128, 0.4)');
              setTimeout(function() {
                $('#email1').css('background', 'rgba(240,128,128,0.3)');
                setTimeout(function() {
                  $('#email1').css('background', 'rgba(240,128,128,0.2)');
                  setTimeout(function() {
                    $('#email1').css('background', 'rgba(240,128,128,0.1)');
                    setTimeout(function() {
                      $('#email1').css('background', 'rgba(240,128,128,0.0)');
                    }, 50);
                  }, 50);
                }, 50);
              }, 50);
            }, 500);
          }
        }
        if(pas1 < 2) {
          setTimeout(function() {
            $('#password1').css('background', 'rgba(240,128,128, 0.1)');
            setTimeout(function() {
              $('#password1').css('background', 'rgba(240,128,128,0.2)');
              setTimeout(function() {
                $('#password1').css('background', 'rgba(240,128,128,0.3)');
                setTimeout(function() {
                  $('#password1').css('background', 'rgba(240,128,128,0.4)');
                  setTimeout(function() {
                    $('#password1').css('background', 'rgba(240,128,128,0.5)');
                  }, 50);
                }, 50);
              }, 50);
            }, 50);
          }, 500);
          if($('#password1').css('background', 'rgba(240,128,128,0.5)')) {
            setTimeout(function() {
              $('#password1').css('background', 'rgba(240,128,128, 0.4)');
              setTimeout(function() {
                $('#password1').css('background', 'rgba(240,128,128,0.3)');
                setTimeout(function() {
                  $('#password1').css('background', 'rgba(240,128,128,0.2)');
                  setTimeout(function() {
                    $('#password1').css('background', 'rgba(240,128,128,0.1)');
                    setTimeout(function() {
                      $('#password1').css('background', 'rgba(240,128,128,0.0)');
                    }, 50);
                  }, 50);
                }, 50);
              }, 50);
            }, 500);
          }
        }
        if(email1 > 4 && pas1 > 1) {
          var pagename = 'email='+email1val+'&password='+pas1val+'&name='+name1val+'&famil='+famil2val;
          sendRequest(pagename);
    
        }
      }
    }

    dannikonov, 16 Ноября 2014

    Комментарии (34)
  8. Pascal / Говнокод #17020

    +140

    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
    type func = function (x : real) : real;
    const
    	eps = 0.0000003;
    	pi = 3.14159265358979;
    function Integral (f : func; a, b : real) : real;
    var center : real;
    begin
    	center := (a + b) / 2;
    	if abs(b - a) < eps then
    		Integral := f(center) * (b - a)
    	else Integral := Integral(f, a, center) + 
    		Integral(f, center, b);
    end;
    function myFunc(x : real) : real;
    begin
    	myFunc := cos(x) / x;
    end;
    begin
    	writeln(Integral(myFunc, pi/2, pi));
    	readln;
    end.

    Толи я дурачек, толи автор кода - школьник....

    ShadowXX, 02 Ноября 2014

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

    +64

    1. 1
    int i;

    кода на самом деле нет, но это достойно говнокод.ру

    на сервере был http метод GET /rest/user/anon/create
    по непонятной причине был заменён на POST /rest/user/anon/create1
    старый метод теперь возвращает 405 ошибку "Method not allowed" с заголовком Allow: POST, OPTIONS

    kyzmitch, 12 Сентября 2014

    Комментарии (34)
  10. PHP / Говнокод #15783

    +162

    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
    <?php
    /**
     * Project:     Smarty: the PHP compiling template engine
     * File:        Smarty.class.php
     *
     * This library is free software; you can redistribute it and/or
     * modify it under the terms of the GNU Lesser General Public
     * License as published by the Free Software Foundation; either
     * version 2.1 of the License, or (at your option) any later version.
     *
     * This library is distributed in the hope that it will be useful,
     * but WITHOUT ANY WARRANTY; without even the implied warranty of
     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
     * Lesser General Public License for more details.
     *
     * You should have received a copy of the GNU Lesser General Public
     * License along with this library; if not, write to the Free Software
     * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
     *
     * For questions, help, comments, discussion, etc., please join the
     * Smarty mailing list. Send a blank e-mail to
     * [email protected] 
     *
     * @link http://www.smarty.net/
     * @copyright 2001-2005 New Digital Group, Inc.
     * @author Monte Ohrt <monte at ohrt dot com>
     * @author Andrei Zmievski <[email protected]>
     * @package Smarty
     * @version 2.6.26
     */
    
    /* $Id: Smarty.class.php 3163 2009-06-17 14:39:24Z monte.ohrt $ */
    
    /**
     * DIR_SEP isn't used anymore, but third party apps might
     */
     echo ".";
     ?>

    Itareo, 18 Апреля 2014

    Комментарии (34)
  11. Pascal / Говнокод #15625

    +88

    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
    var 
      s: string := '1 2 4 8 16 32 64 128 256 512';
      sum: integer;
      num,p: integer;
      numstr: string;
    begin
      sum := 0;
      while s.Length>0 do
      begin
        while s[1]=' ' do // Удаление лидирующих пробелов
          Delete(s,1,1);
        p := Pos(' ',s); // Поиск следующего пробела
        if p=0 then      // Если он не найден, то до конца строки находится последнее число
          p := s.Length;
        numstr := Copy(s,1,p);
        Delete(s,1,p);
        num := StrToInt(numstr);
        sum += num;
      end;
      writeln('Сумма чисел строки равна ',sum);
    end.

    "Pascal" не умеет в split?
    http://pascalabc.net/wiki/index.php/Строки_и_символы._Тексты_программ

    gost, 31 Марта 2014

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