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

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

    −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
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    26. 26
    #include <stdio.h>
    #include <iostream>
    #include <regex>
    using namespace std;
    int cube(int);
    int main()
    {
            char number;
            label:
            cout << " Введите число " << endl;
            cin >> number;
            regex txt_regex("/^\d+$/");
        if (!regex_match(number, txt_regex))
        {
            cout << "Вводить можно только цифры!" << endl;
            goto label;
        }
        int value = atoi(number);
            int result = cube(value);
            cout << "Куб числа " << number << " равен " << result;
        return 0;
    }
    int cube(int number)
    {
          return number * number * number; 
    }

    Возведение числа в куб.

    Exclumice, 30 Сентября 2015

    Комментарии (21)
  3. JavaScript / Говнокод #18655

    +3

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    if (!$('#enable-continious').is(':checked') && $('#enable-continious').is(':checked')) {
    	...
    } else {
    	...
    }

    Продолжаем находить великие письмена великих людей на проекте. К слову, человек на позиции Senior PHP Developer является автором.

    Un3Solka, 31 Августа 2015

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

    +4

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    with TfmVersionUpdate.Create(Application) do
    begin
      try
        Init;
      except
      end;
      Free;
    end;

    Такой код 100500% отработает без ошибок. Зачем вообще сообщения о них выводить...

    kiryl, 19 Августа 2015

    Комментарии (21)
  5. JavaScript / Говнокод #18397

    +144

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    if (['text'].indexOf(data[a]['input']) === 'date') {
         data[a]['value'][f].subscribe(function (nv) {
             self.pollChanges();
        })
    }

    lord_rb, 24 Июня 2015

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

    +144

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    catch (Exception ex)
                {
                    status = ex.Message;
                    throw ex;
                }

    zhilinskyegor, 07 Мая 2015

    Комментарии (21)
  7. Python / Говнокод #18011

    −241

    1. 1
    2. 2
    3. 3
    def __repr__(self):
            # почему здесь бесконечная рекурсия?
            return repr(self.__repr__)

    3_14dar, 17 Апреля 2015

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

    +57

    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
    #include <iostream>
    #include <stdexcept>
    
    template<std::size_t N>
    static int constexpr date_component(const char (&s)[N], int i, bool last, int max) {
      return 
        (i + 2 + (last ? 0 : 1) >= N) 
            ? throw std::logic_error("Too short date string") :
        (!last && s[i + 2] != ':') 
            ? throw std::logic_error("Cannot find delimiter") :
        (s[i] < '0' || s[i] > '9' ||  s[i + 1] < '0' || s[i + 1] > '9') 
            ? throw std::logic_error("Not a number") :
        ((s[i] - '0') * 10 + (s[i + 1] - '0') > max) 
            ? throw std::logic_error("Too large number") :
                (s[i] - '0') * 10 + (s[i + 1] - '0');
    }
    
    struct time { 
        int hour; int minute; int second; 
        
        template<std::size_t N>
        constexpr time(const char (&datestr)[N]) :
            hour(date_component(datestr, 0, false, 24)), 
            minute(date_component(datestr, 3, false, 60)),
            second(date_component(datestr, 6, true, 60)) 
        {}
    };
    
    struct time constexpr midnight("00:00:00");
    struct time constexpr afternoon("12:00:00");
    
    int main(int argc, char* argv[]) {
        std::cout << "Midnight hour is " << midnight.hour << std::endl;
        std::cout << "Afternoon hour is " << afternoon.hour << std::endl;
    }

    C++ и даты времени компиляции

    myaut, 03 Апреля 2015

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

    +164

    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
    function addnews($str1="", $str2="", $str3="", $str4="", $str5=""){
      $num = 0;
      $done = 0;
      while ($done == 0){
        $num++;
        $s = "";
        if ($num<10000000) {$s="0".$s;}
        if ($num<1000000)  {$s="0".$s;}
        if ($num<100000)   {$s="0".$s;}
        if ($num<10000)    {$s="0".$s;}
        if ($num<1000)     {$s="0".$s;}
        if ($num<100)      {$s="0".$s;}
        if ($num<10)       {$s="0".$s;}
    	$done = 1;
    	if (file_exists("news/".$s.$num.".txt")){$done=0;}
      }
      $fh1 =fopen("news/".$s.$num.".txt","w");
      fwrite($fh1, $str1."\r\n");
      fwrite($fh1, $str2."\r\n");
      fwrite($fh1, $str3."\r\n");
      fwrite($fh1, $str4."\r\n");
      fwrite($fh1, $str5);
      fclose($fh1);
    }

    Предложили доработать корпоративную тикет-систему. Движок абсолютно всё хранит в txt-файлах. Да, и пароли пользователей тоже - в открытом виде. БД? Нет, не слышали :(
    Но это еще не так страшно...

    Arris, 26 Марта 2015

    Комментарии (21)
  10. C++ / Говнокод #17750

    +54

    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
    void Game::initialize()
    {
        if (SDL_Init(SDL_INIT_VIDEO))
            exit(1);
        
        window = new Window("Game", 640, 480);
        try
        {
            window->create();
        }
        catch (const Exception& exception)
        {
            std::cout << exception.getError() << '\n';
            delete window;
            exit(1);
        }
        
        canvas = new Canvas();
        try
        {
            canvas->initialize(window->getWindow());
        }
        catch (const Exception& exception)
        {
            std::cout << exception.getError() << '\n';
            delete canvas;
            exit(1);
        }
    }

    jangolare, 09 Марта 2015

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

    +157

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    function getMinQueueOrdering()
      {
        $sql="SELECT MAX(ordering)
              FROM priceloaddata_queue";
      .........
      }

    нет слов.

    Vasiliy, 19 Февраля 2015

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