1. C# / Говнокод #18116

    +144

    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
    public string[] razborstroki(string str)
            {
                string[] array = new string[100];
                int j = 0;
                for (int i = 0; i < str.Length; i++)
                {
                    if (str[i] != ';')
                        array[j] += str[i];
                    else
                        j++;
                }
                return array;
            }

    Обнаружил недавно в одном из переданных нам проектов. Правильно, у нас будет свой split с маджонгом и гейшами!!!!

    flea3m, 05 Мая 2015

    Комментарии (0)
  2. Ruby / Говнокод #18115

    −92

    1. 1
    errors[:please] « "fill one more field"

    Ruby On Rails. Крутяк)

    zhilinskyegor, 05 Мая 2015

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

    +143

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    void MyWindow::OkButtonClicked()
    {
        if((!cb1->isChecked()) && (!cb2->isChecked()))
            emit Simple(line->text());
        if((cb1->isChecked()) && (!cb2->isChecked()))
            emit Register(line->text());
        if((!cb1->isChecked()) && (cb2->isChecked()))
            emit Invers(line->text());
        if((cb1->isChecked()) && (cb2->isChecked()))
            emit RegVers(line->text());
    }

    dia, 05 Мая 2015

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

    +143

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    function CopyEx(s:string; index,count:integer):string;
    var
      len,ln:integer;
    begin
      ln:=0;
      if index <1 then index:=1;
      len:=length(s);
      ln:=len-count;
      dec(ln);
      dec(len,(index+ln));
      result:=copy(s,index,len);
    end;

    Stertor, 04 Мая 2015

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

    +144

    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
    <?php
    
    $startNumber = 0;
    
    function LittlePart($BigPart, $startNumber) {
      $i = -3;
      $number = $startNumber * M_PI + ($i - 1);
      do {
        $number += M_PI;
        echo $BigPart . ' + (' . $i . ') = ' . number_format($number, 2, ',', ' ') . PHP_EOL;
        $i++;
      } while ($i <= 3);
    }
    
    
    function MidPart($BigPart, $startNumber) {
      $i = -3;
      $number = $startNumber * M_PI + ($i - 1);
      do {
        $number += M_PI;
        LittlePart ($BigPart . ' + (' . $i . ')·π', $number);
        $i++;
      } while ($i <= 3);
    }
    
    
    function QuadradPart($BigPart, $startNumber) {
      $i = -3;
      $number = $startNumber * M_PI + ($i - 1);
      do {
        $number += M_PI;
        MidPart ($BigPart . ' + (' . $i . ')·π²', $number);
        $i++;
      } while ($i <= 3);
    }
    
    function CubePart($BigPart, $startNumber) {
      $i = -3;
      $number = $startNumber * M_PI + ($i - 1);
      do {
        $number += M_PI;
        QuadradPart ($BigPart . '(' . $i . ')·π³', $number);
        $i++;
      } while ($i <= 3);
    }
    
    
    CubePart('', 0);

    Система счисления по основанию π. Пока с целыми числами.

    http://ideone.com/EUYEKA

    inkanus-gray, 03 Мая 2015

    Комментарии (24)
  6. JavaScript / Говнокод #18109

    +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
    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
    function num_to_sxg($n) {
     $s = "";
     $m = "0123456789ABCDEFGHJKLMNPQRSTUVWXYZ_abcdefghijkmnopqrstuvwxyz";
     if ($n===undefined || $n===0) { return 0; }
     while ($n>0) {
       $d = $n % 60;
       $s = strcat($m[$d],$s);
       $n = ($n-$d)/60;
     }
     return $s;
    }
    
    function num_to_sxgf($n, $f) {
     $s = num_to_sxg($n);
     if ($f===undefined) { 
       $f=1; 
     }
     $f -= strlen($s);
     while ($f > 0) { 
       $s = strcat("0",$s); 
       --$f; 
     }
     return $s;
    }
    
    function sxg_to_num($s) {
     $n = 0;
     $j = strlen($s);
     for ($i=0;$i<$j;$i++) { // iterate from first to last char of $s
       $c = ord($s[$i]); //  put current ASCII of char into $c  
       if ($c>=48 && $c<=57) { $c=$c-48; }
       else if ($c>=65 && $c<=72) { $c-=55; }
       else if ($c==73 || $c==108) { $c=1; } // typo capital I, lowercase l to 1
       else if ($c>=74 && $c<=78) { $c-=56; }
       else if ($c==79) { $c=0; } // error correct typo capital O to 0
       else if ($c>=80 && $c<=90) { $c-=57; }
       else if ($c==95) { $c=34; } // underscore
       else if ($c>=97 && $c<=107) { $c-=62; }
       else if ($c>=109 && $c<=122) { $c-=63; }
       else { $c = 0; } // treat all other noise as 0
       $n = 60*$n + $c;
     }
     return $n;
    }

    Угадайте, какой это язык и что пил автор.

    http://ideone.com/87cVrr

    http://ideone.com/Z8j7ve

    solnze_dar, 02 Мая 2015

    Комментарии (12)
  7. Си / Говнокод #18108

    +143

    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
    // Exported Functions
    #ifdef __cplusplus
    extern "C" {
    #endif
    
        ...
    
    DLLEXPORT FPDF_DEST STDCALL FPDF_GetNamedDest(FPDF_DOCUMENT document, int index, void* buffer, long& buflen);
    
    
    #ifdef __cplusplus
    };
    #endif

    https://pdfium.googlesource.com/pdfium/+/master/fpdfsdk/include/fpdfview.h

    Intended to be C-compatible source.

    vasvas, 02 Мая 2015

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

    +148

    1. 1
    2. 2
    //G++ now allows typename in a template template parameter.
        template<template<typename> typename X> struct D; // xzibit.jpeg

    Пятый gcc вышел. Больше крестоблядства за те же деньги.
    https://gcc.gnu.org/gcc-5/changes.html

    3.14159265, 02 Мая 2015

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

    +143

    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
    MyNumber(String n) {
           try {
               for (int i = 0; i < n.length(); i++) {  
                    numbers[i] = charToInt(n.charAt(i));
               }
           } catch (InvalidArgumentException e) {
               e.printStackTrace();
           }
        }
    
        public int charToInt(char c) throws InvalidArgumentException{
            char[] digits = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9'};
    
            for (int i = 0; i < 10; i++) {
                if (digits[i] == c) return i;
            }
    
            throw new InvalidArgumentException(null);
        }

    Попросили быстро написать перевод числа, закодированного в строку, в массив его цифр.

    Govnocoder#0xFF, 01 Мая 2015

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

    +144

    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
    class Select
      constructor: ->
        Select = this
    
    
    ###
    
    var Select;
    
    Select = (function() {
      function Select() {
        Select = this;
      }
    
      return Select;
    
    })();

    код на coffeescript. до сих пор годаю - зачем?

    frozfox, 01 Мая 2015

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