1. Pascal / Говнокод #8280

    +147

    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
    program s_27;
    uses crt;
    function SummaCifr(n:integer):byte;
    
    var s,
        x:integer;
    {----------------------------------------------------------------------------}
    begin
      clrscr;
      s:=0;
      x:=n;
      while x>0 do begin
        s:=s+(x mod 10);
    
        x:=x div 10;
      end;
      SummaCifr:=s;
    end;
    {----------------------------------------------------------------------------}
    var i,k:integer;
    begin
      i:=2;
      k:=99;
      while SummaCifr(k)<>27 do
      begin
        k:=i*99;
        inc(i);
      end;
      WriteLn('Rezult:',k);
      ReadLn;
    end.

    поиск числа!

    ITdocer, 23 Октября 2011

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

    +146

    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
    #include<stdio.h>
    #include<conio.h>
    #include<math.h>
    #include<stdlib.h>
    void main(){
    int Kliuci,X,Y,a,b,interval=10;
    float T,sum=0;
    m3:
    clrscr();
    printf("\n\r  *****************\n\r");
    printf("     1|FOR\n\r");
    printf("     2|WHILE\n\r");
    printf("     0|EXIT\n\r");
    printf("       ****************\n\r");
    printf("Vvedite Kliuci:");
    scanf("%d",&Kliuci);
    switch(Kliuci)
    {case 1 :
    {//for
    printf("Vvedite znacenia:a,b\n");
    scanf("%d%d",&a,&b);
    printf("Vvedite interval min 10 X=n<Y+Y:\n");
    scanf("%d%d",&X,&Y);
    printf("\n\r   ********RESULT*******\r");
    printf("\n\r    --Interval-----Rezulitat\n\r");
    for(int k=X*X;k<Y+1;k++)
    {
    T=pow(b,2)+a/2+(pow(a,4)/4)-(pow(b,6)/6)+k;
    printf("  |\t %d",k);
    printf("-");
    printf("\t  %f \n\r",T);
    interval++;
    sum+=T; }
    printf("\n\r  *********************\n\r");
    printf("Vesi interval:%d\n\r",interval);
    printf("Vesi rezulitat: %f",sum);
    getch();}
    break;
    case 2:
    {//while
    printf("Vvedite znacenia:a,b\n");
    scanf("%d%d",&a,&b);
    printf("Vvedite interval min 10 X=n<Y+Y:\n");
    scanf("%d%d",&X,&Y);
    printf("\n\r   ********RESULT********\r");
    printf("\n\r    --Interval-----Rezulitat\n\r");
    int k=X*X;
    while(k<Y+1)
    T=pow(b,2)+a/2+(pow(a,4)/4)-(pow(b,6)/6)+k;
    k++;
    printf("  |\t %d",k);
    printf("-");
    printf("\t  %f \n\r",T);
    interval++;
    sum+=T; }
    printf("\n\r  **********************\n\r");
    printf("Vesi interval:%d\n\r",interval);
    printf("Vesi rezulitat: %f",sum);
    getch();
    break;
    case 0:
    exit(0); }
    break;
    }
    goto m3;}

    http://hashcode.ru/questions/45871/где-ошибки-не-работает-компильтор

    >goto
    >void main
    >...

    TheHamstertamer, 23 Октября 2011

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

    +1004

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    init1(); 
    !isFailed1() && init2(); 
    !isFailed1() && !isFailed2() && init3(); 
    !isFailed1() && !isFailed2() && !isFailed3() && work();
    !isFailed3() && cleunUp3(); 
    !isFailed2() && cleunUp2(); 
    !isFailed1() && cleunUp1();

    И этот думает, что RAII не нужен.

    AnimeGovno-_-, 22 Октября 2011

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

    +1000

    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
    int i = 0;
    
    init1();
    ++i;
    if (!isFailed1()) goto clean_up;
    
    init2();
    ++i;
    if (!isFailed2()) goto clean_up;
    
    init3();
    ++i;
    if (!isFailed3()) goto clean_up;
    
    goto end:
    
    clean_up:
    
    switch(i) {
      case 3:
        cleunUp3();
      case 2:
        cleunUp2();
      case 1:
        cleunUp1();
    }
    
    end:

    Он думает, что RAII не нужен.

    AnimeGovno-_-, 22 Октября 2011

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

    +997

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    list<int> l;
    //...
    for(int i=0;i<l.size();++i)
    {
     auto it=l.begin();
     advance(it, i);
     int item=*it;
     //...

    AnimeGovno-_-, 22 Октября 2011

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

    +163

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    Электронная почта (e-mail) - если указано, то проверяем корректность
    
    p_email = document.myform.email.value.toString();
    if (p_email != "") {
    t = p_email.indexOf("@");
    if((p_email.indexOf(".") == -1) || (t == -1) || (t < 1) || (t > p_email.length - 5) || (p_email.charAt(t - 1) == '.') || (p_email.charAt(t + 1) == '.')) {
    alert("Некорректно указан E-mail !");
    document.myform.email.focus();
    return false;
    }
    }

    http://www.whatis.ru/razn/razn14.shtml

    denis90, 22 Октября 2011

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

    +80

    1. 1
    2. 2
    3. 3
    4. 4
    getBtnContent().setEnabled(enable);
    if (getGridConfig().isContentEnabled()) {
           getBtnContent().setEnabled(enable);
    }

    Программист со стажем, всегда хочет быть уверен что кнопка будет доступна на 150%

    pvtPyle, 22 Октября 2011

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

    +116

    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
    <Grid Grid.Row="2" Margin="5">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition/>
                    <ColumnDefinition/>
                    <ColumnDefinition/>
                </Grid.ColumnDefinitions>
                <Grid.RowDefinitions>
                    <RowDefinition Height="auto"/>
                    <RowDefinition Height="auto"/>
                    <RowDefinition Height="auto"/>
                    <RowDefinition Height="auto"/>
                    <RowDefinition Height="auto"/>
                    <RowDefinition Height="auto"/>
                    <RowDefinition Height="auto"/>
                </Grid.RowDefinitions>
                <ContentPresenter Grid.Row="0" Grid.Column="0" Content="{Binding ElementName=root,Path=Items[0]}"/>
                <ContentPresenter Grid.Row="0" Grid.Column="1" Content="{Binding ElementName=root,Path=Items[1]}"/>
                <ContentPresenter Grid.Row="0" Grid.Column="2" Content="{Binding ElementName=root,Path=Items[2]}"/>
                <ContentPresenter Grid.Row="1" Grid.Column="0" Content="{Binding ElementName=root,Path=Items[3]}"/>
                <ContentPresenter Grid.Row="1" Grid.Column="1" Content="{Binding ElementName=root,Path=Items[4]}"/>
                <ContentPresenter Grid.Row="1" Grid.Column="2" Content="{Binding ElementName=root,Path=Items[5]}"/>
                <ContentPresenter Grid.Row="2" Grid.Column="0" Content="{Binding ElementName=root,Path=Items[6]}"/>
                <ContentPresenter Grid.Row="2" Grid.Column="1" Content="{Binding ElementName=root,Path=Items[7]}"/>
                <ContentPresenter Grid.Row="2" Grid.Column="2" Content="{Binding ElementName=root,Path=Items[8]}"/>
                <ContentPresenter Grid.Row="3" Grid.Column="0" Content="{Binding ElementName=root,Path=Items[9]}"/>
                <ContentPresenter Grid.Row="3" Grid.Column="1" Content="{Binding ElementName=root,Path=Items[10]}"/>
                <ContentPresenter Grid.Row="3" Grid.Column="2" Content="{Binding ElementName=root,Path=Items[11]}"/>
                <ContentPresenter Grid.Row="4" Grid.Column="0" Content="{Binding ElementName=root,Path=Items[12]}"/>
                <ContentPresenter Grid.Row="4" Grid.Column="1" Content="{Binding ElementName=root,Path=Items[13]}"/>
                <ContentPresenter Grid.Row="4" Grid.Column="2" Content="{Binding ElementName=root,Path=Items[14]}"/>
                <ContentPresenter Grid.Row="5" Grid.Column="0" Content="{Binding ElementName=root,Path=Items[15]}"/>
                <ContentPresenter Grid.Row="5" Grid.Column="1" Content="{Binding ElementName=root,Path=Items[16]}"/>
                <ContentPresenter Grid.Row="5" Grid.Column="2" Content="{Binding ElementName=root,Path=Items[17]}"/>
                <ContentPresenter Grid.Row="6" Grid.Column="0" Content="{Binding ElementName=root,Path=Items[18]}"/>
                <ContentPresenter Grid.Row="6" Grid.Column="1" Content="{Binding ElementName=root,Path=Items[19]}"/>
                <ContentPresenter Grid.Row="6" Grid.Column="2" Content="{Binding ElementName=root,Path=Items[20]}"/>            
            </Grid>

    legat, 22 Октября 2011

    Комментарии (6)
  9. Си / Говнокод #8272

    +141

    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
    char *zamena(int m)
     {
       char *s;
       int a,b,c;
       a = m / 100;
       b=(m / 10)% 10;
       c=m % 10;
       if (a>0)
       switch (a)   
       {
        case 1: s=s+"сто ";
        case 2: s=s+"двести ";
        case 3: s=s+"триста ";
        case 4: s=s+"четыреста ";
        case 5: s=s+"пятьсот ";
        case 6: s=s+"шестьсот ";
        case 7: s=s+"семьсот ";
        case 8: s=s+"восемьсот ";
        case 9: s=s+"девятьсот ";
       }
       if (b==1) 
        switch (c)
       {
        case 1: s=s+"одиннадцать ";
        case 2: s=s+"двенадцать ";
        case 3: s=s+"тринадцать ";
        case 4: s=s+"четырнадцать ";
        case 5: s=s+"пятнадцать ";
        case 6: s=s+"шестнадцать ";
        case 7: s=s+"семнадцать ";
        case 8: s=s+"восемнадцать ";
        case 9: s=s+"девятнадцать ";
       }
       else
        switch (b)
       {
        case 2: s=s+"двадцать ";
        case 3: s=s+"тридцать ";
        case 4: s=s+"сорок ";
        case 5: s=s+"пятьдесят ";
        case 6: s=s+"шестьдесят ";
        case 7: s=s+"семьдесят ";
        case 8: s=s+"восемьдесят ";
        case 9: s=s+"девяносто ";
       }
       if (b!=1 && c>0) 
        switch (c)
       {
        case 1: s=s+"один ";
        case 2: s=s+"два ";
        case 3: s=s+"три ";
        case 4: s=s+"четыре ";
        case 5: s=s+"пять ";
        case 6: s=s+"шесть ";
        case 7: s=s+"семь ";
        case 8: s=s+"восемь ";
        case 9: s=s+"девять ";
       }
       return s;
     }

    Перевод целого числа в строку.

    Proger, 22 Октября 2011

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

    +161

    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
    $searchCondition1 = ''; 
     $searchCondition2 = ''; 
     $searchCondition3 = ''; 
     $flag = false; 
     $sql = 'SELECT f.flight_id,
                   (SELECT city
                    FROM airports
                    WHERE airport_id = f.from) as _from,
                   (SELECT city
                    FROM airports
                    WHERE airport_id = f.to) as _to,
                    f.flight_date as fdate,
                    f.flight_time,
                    f.distance,
                    p.plain_name as plain
            FROM flight f JOIN planes p
                ON f.plain_id = p.plain_id
            WHERE '; 
     $fields = 0; 
     if($_POST['txtSearch']){ 
         if($_POST['txtFrom'] != ''){ 
             $searchCondition1 = " city = '".$_POST['txtFrom']."'"; 
             $flag = true; // set flag to TRUE
             $fields++; 
         }
         if($_POST['txtTo'] != ''){ // if To field is not empty
             $searchCondition2 = " city = '".$_POST['txtTo']."'"; 
             $flag = true;  // set flag to TRUE
             $fields++; 
         }
         if ($_POST['txtDate'] != ''){ // if Date field is not empty
             $searchCondition3 = " DATE(f.flight_date) = '".$_POST['txtDate']."'";
             $fields++; // and inc 
         }
         if($fields == 0){                             
             echo "<br/><div style=\"color:red\">Please, enter at least one filed to search</div>"; 
         }else{ 
             if($searchCondition1 != '' && $searchCondition2 == ''){ 
             $sql .= " f.from IN (SELECT airport_id
                                        FROM airports
                                        WHERE ".$searchCondition1.")"; 
             }
             if($searchCondition1 == '' && $searchCondition2 != ''){ 
                 $sql .= " f.to IN (SELECT airport_id
                                            FROM airports
                                            WHERE ".$searchCondition2.")"; 
             }                                                              
             if($searchCondition1 != '' && $searchCondition2 != ''){ 
                 $sql .= " f.from IN (SELECT airport_id
                                            FROM airports
                                            WHERE ".$searchCondition1.")
                                 AND f.to IN (SELECT airport_id
                                            FROM airports
                                            WHERE ".$searchCondition2.")"; 
             }
             if($searchCondition3 != ''){ 
                 if($flag){ 
                     $sql .= " AND ".$searchCondition3; 
                 }else{
                     $sql .= $searchCondition3; 
                 }
    
             }
             include_once('database.php'); 
             $db = createPDO();
             $result = $db->query($sql);
             echo '<table>
                  <tr>
                    <th>
                        From
                    </th>
                    <th>
                        To
                    </th>
                    <th>
                        Flight Date
                    </th>
                    <th>
                        Flight Time
                    </th>
                    <th>
                        Distance
                    </th>
                    <th>
                        Plane
                    </th>
                    <th>
                        Action
                    </th>
                </tr>'; // create an HTML table with headers
             while($row = $result->fetch()){...}

    Ищем в табличке в зависимости от заполненных полей в форме

    denis90, 22 Октября 2011

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