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

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

    −1

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    Func<int,int> fact = (int i_in) => i_in;
    
    fact = (int i_in) =>
    {
    	if (i_in>1) return (fact(i_in-1)*i_in);
    	else return (1);
    };

    tucvbif, 29 Января 2016

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

    +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
    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
    protected override void mergeModels(IStuff Stuff, IStuff With)
            {
                var stuff = (MyObject)Stuff;
                var with = (MyObject)With;
    
                if (with.title != null)
                    stuff.title = with.title;
    
                if (with.description != null)
                    stuff.description = with.description;
                if (with.creator != null)
                    stuff.creator = with.creator;
                if (with.status != null)
                    stuff.status = with.status;
                if (with.client_name != null)
                    stuff.client_name = with.client_name;
                if (with.client_mail != null)
                    stuff.client_mail = with.client_mail;
                if (with.client_phone != null)
                    stuff.client_phone = with.client_phone;
                if (with.folder != null)
                    stuff.folder = with.folder;
    
                if (with.flag1 != null)
                    stuff.flag1 = with.flag1;
                if (with.flag2 != null)
                    stuff.flag2 = with.flag2;
                if (with.flag3 != null)
                    stuff.flag4 = with.flag3;
                if (with.flag4 != null)
                    stuff.flag4 = with.flag4;
                if (with.flag5 != null)
                    stuff.flag5 = with.flag5;
                if (with.flag6 != null)
                    stuff.flag6 = with.flag6;
                if (with.flag7 != null)
                    stuff.flag7 = with.flag7;
            }

    Копирование данных из одного объекта в другой.

    yakov_255, 19 Января 2016

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

    +1

    1. 1
    2. 2
    halve :: [a] -> ([a], [a])
    halve xs = (\xs mf -> (take (mf xs) xs, drop (mf xs) xs)) xs (\l -> (div (length l) 2))

    делим список пополам
    ЧЯДНТ?

    schwrzwldr_gbln, 17 Января 2016

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

    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
    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
    #include <iostream>
    #include <vector>
    #include <cmath>
    #include <algorithm>
    #include <stdio.h>
     
    std::vector<int> A, B, C;
     
    void build(const std::vector<int> A, int k, int razmer){
            int n = razmer;
            B.resize(n);
            C.resize(n);
            B.front() = A.front();
            C.back() = A.back();
     
            k--;
     
            for(int i1(1), i2(n - 2); i1 < n; i1++, i2--){
                    B[i1] = (i1 % k) ? std::max(A[i1], B[i1 - 1]) : A[i1];
                    C[i2] = ((i2 + 1) % k) ? std::max(A[i2], C[i2 + 1]) : A[i2];
            }
    }
     
    int main(){
            int m, count;
            A.resize(100001);
            scanf("%d", &m);
            count = 0;
     
            while(true){
                    scanf("%d", &A[count]);
                    if(A[count] == -1) break;
                    count++;
            }
     
            build(A, m, count);
            int l = 0;
            while(count - 1 >= m){
                    printf("%d\n", std::max(C[l], B[l + m - 1]));
                    l++;
            }
            return 0;
    }

    Код, реализующий поиск максимума по подотрезках последовательности чисел. Если непонятно, то тут строится дерево отрезков, и потом с ним происходит какая-то ебола. Красивое решение получается при использовании стандартного алгоритма поиска максимума в очереди за O(1) при помощи двух стеков.

    HiewMorjowie, 12 Декабря 2015

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

    0

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    $HighSpeed = new HighLoad();
    	$redis = new Redis();
    	$redis->connect($HighSpeed->passwd);
    	$redis->auth('ХХХХХХХХХХХХХХХ');
    	$redis->select(1);

    Всё что после первой строки уже реализовано в самом классе

    proweb, 10 Ноября 2015

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

    +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
    var code = '\
    int sum(int a, int b) {\
       __asm {\
          mov eax, a;\
          add eax, b;\
          mov a, eax;\
       }\
       return a;\
    }';
    
    var sum = cpp2js(code);
    var ans = sum(34, 288);
    alert(ans);

    http://www.speqmath.com/tutorials/cpp2js/index.html

    3_dar, 07 Ноября 2015

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

    +4

    1. 1
    2. 2
    3. 3
    function Head($p1) {
    echo '<!DOCTYPE html><html><head><meta charset="utf-8" /><title>'.$p1.'</title><meta name="keywords" content="" /><meta name="description" content="" /><link href="/resource/style.css" rel="stylesheet"><link rel="icon" href="/resource/img/favicon.ico" type="image/x-icon"><script src="//mc.yandex.ru/metrika/watch.js" type="text/javascript"></script><script type="text/javascript">try {var yaCounter30971061 = new Ya.Metrika({id:30971061});}catch(e){}</script></head>';
    }

    шедевры от #Mr.shitcode (для своих адептов - mr.shift)
    за такой вывод html нужно отрывать руки

    loki90, 24 Октября 2015

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

    +2

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    9. 9
    case ((((parametr[3, 1] - parametr[1, 1]) / parametr[4, 2] = (parametr[3, 2] - parametr[1, 2]) / parametr[4, 2]) and ((parametr[3, 2] - parametr[1, 2]) / parametr[4, 2] = (parametr[3, 3] - parametr[1, 3]) / parametr[4, 3])) xor           
                ((parametr[4, 1] = 0) and (parametr[1, 1] = parametr[2, 1]) and (parametr[2, 1] = parametr[3, 1]) and ((parametr[3, 2] - parametr[1, 2]) / parametr[4, 2] = (parametr[3, 3] - parametr[1, 3]) / parametr[4, 3])) xor          
                 ((parametr[4, 2] = 0) and (parametr[1, 2] = parametr[2, 2]) and (parametr[2, 2] = parametr[3, 2]) and ((parametr[3, 1] - parametr[1, 1]) / parametr[4, 1] = (parametr[3, 3] - parametr[1, 3]) / parametr[4, 3])) xor                           
                    ((parametr[4, 3] = 0) and (parametr[1, 3] = parametr[2, 3]) and (parametr[2, 3] = parametr[3, 3]) and ((parametr[3, 1] - parametr[1, 1]) / parametr[4, 1] = (parametr[3, 2] - parametr[1, 2]) / parametr[4, 2])) xor             
                       ((parametr[4, 3] <> 0) and (parametr[4, 1] = 0) and (parametr[4, 2] = 0) and (parametr[3, 1] = parametr[2, 1]) and (parametr[3, 2] = parametr[2, 2])) xor                    
                          ((parametr[4, 2] <> 0) and (parametr[4, 1] = 0) and (parametr[4, 3] = 0) and (parametr[3, 1] = parametr[2, 1]) and (parametr[3, 3] = parametr[2, 3])) xor                       
                             ((parametr[4, 1] <> 0) and (parametr[4, 2] = 0) and (parametr[4, 3] = 0) and (parametr[3, 2] = parametr[2, 2]) and (parametr[3, 3] = parametr[2, 3])) xor                         
                                ((parametr[4, 1] = 0) and (parametr[4, 2] = 0) and (parametr[4, 3] = 0))) of true:
             writeln('Все точки лежат на одной прямой. Такой треугольник не существует.');

    Проверка треугольника в декартовой системе координат

    Meliodas, 04 Октября 2015

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

    +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
    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
    95. 95
    96. 96
    {header}
    
    <p style="font-weight: bold; text-decoration: underline">{$orgName}</p>
    
    <p style="font-weight: bold">Адреса: {$orgBillingAddress}, тел.: {$orgPhone}</p>
    
    <div style="font-weight: bold; text-align: center">Зразок заповенння платіжного доручення</div>
    
    <table border="1" cellpadding="2">
    <tr>
      <td width="140">ЄДРПО {$orgInn}</td><td width="140">ІДПРС {$orgKpp}</td><td rowspan="2" width="50"><br/><br/>Рахунок. №</td><td rowspan="2" width="200"><br/><br/>{$orgBankAccount}</td>
    </tr>
    <tr>
    <td colspan="2" width="280"><span style="font-size: 8pt">Одержувач</span><br/>{$orgName}</td>
    </tr>
    <tr>
    <td colspan="2" rowspan="2" width="280"><span style="font-size: 8pt">Банк отримувача</span><br/>{$orgBankName}</td>
    <td width="50">БІК</td>
    <td rowspan="2" width="200">{$orgBankId}<br/>{$orgCorrAccount}</td>
    </tr>
    <tr>
    <td width="50">Рахунок. №</td>
    </tr>
    </table>
    <br/>
    <h1 style="text-align: center">Рахунок № {$invoice_no} від {$invoice_invoicedate}</h1>
    <br/><br/>
    <table border="0">
    <tr>
    <td width="100">Платник:</td><td width="450"><span style="font-weight: bold">{$account_accountname}</span></td>
    </tr>
    <tr>
    <td width="100">Одержувач:</td><td width="450"><span style="font-weight: bold">{$orgName}</span></td>
    </tr>
    </table>
    
    {/header}
    
    {table_head}
    <table border="1" style="font-size: 8pt" cellpadding="2">
        <tr style="text-align: center; font-weight: bold">
    	<td width="30">№</td>
          <td width="260">Назва<br/>товару</td>
          <td width="65">Одиниця<br/>вимір-<br/>рювання</td>
          <td width="35">Кіль-<br/>кість</td>
    	<td width="70">Ціна</td>
    	<td width="70">Сумма</td>
    	</tr>
    {/table_head}
    
    {table_row}
        <tr>
    	<td width="30">{$productNumber}</td>
          <td width="260">{$productName} {$productComment}</td>
    	<td width="65" style="text-align: center">{$productUnits}</td>
    	<td width="35" style="text-align: right">{$productQuantityInt}</td>
    	<td width="70" style="text-align: right">{$productPrice}</td>
    	<td width="70" style="text-align: right">{$productNetTotal}</td>
        </tr>
    {/table_row}
    
    {summary}
    </table>
    <table border="0" style="font-size: 8pt;font-weight: bold">
        <tr>
          <td width="460">
            <table border="0" cellpadding="2">
              <tr><td width="460" style="text-align: right">Разом:</td></tr>
              <tr><td width="460" style="text-align: right">Сумма ПРД:</td></tr>
              <tr><td width="460" style="text-align: right">Всього до сплати:</td></tr>
            </table>
          </td>
          <td width="70">
            <table border="1" cellpadding="2">
              <tr><td width="70" style="text-align: right">{$summaryNetTotal}</td></tr>
              <tr><td width="70" style="text-align: right">{$summaryTax}</td></tr>
              <tr><td width="70" style="text-align: right">{$summaryGrandTotal}</td></tr>
            </table>
          </td>
      </tr>
    </table>
    
    <p>
    Всього найменувань {$summaryTotalItems}, на сумму {$summaryGrandTotal} грн.<br/>
    <span style="font-weight: bold">{$summaryGrandTotalLiteral}</span>
    </p>
    
    {/summary}
    
    {ending}
    <br/>
        <p>Крівник підприємства  __________________ ( {$orgDirector} ) <br/>
        <br/>
        Головний бухгалтер  __________________ ( {$orgBookkeeper} )
        </p>
    {/ending}

    генератор пдф

    igorko, 01 Октября 2015

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

    +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
    <?php
    $connect=mysql_connect('localhost', 'gvm.12', '963741258') or die(mysql_error());
    mysql_select_db('gvm.12');
    if(isset($_POST['enter']))
    {
    $login_=$_POST['login_'];
    $password_=md5($_POST['password_']);
    
    $query=mysql_query("SELECT * FROM  users WHERE login='$login_'");
    $user_data=mysql_fetch_array($query);
    if($user_data['password']==$password_)
    {
    echo "You have succesfully enter";
    $check=true;
    }
    else 
    {
    echo "wrong login or password";
    }
    }
    ?>

    Просто пиздец!

    webalex127, 15 Сентября 2015

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