1. PHP / Говнокод #11782

    +74

    1. 1
    2. 2
    //переворачиваем массив с ног на голову, отрезаем голову, чтоб осталось 10 элементов и ставим все что осталось на ноги
    $_lasts = array_reverse(array_splice(array_reverse($last_view), 5));

    "казнь" массива

    Mihard, 17 Сентября 2012

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

    +38

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    SkinDog* crateDog()
    {
      return reinterpret_cast<SkinDog*>( new Dog() );
    };
    void deleteDog( SkinDog* pDog)
    {
      delete reinterpret_cast<Dog*>( pDog );
    }
    
    EvilDog::bite() 
    {
      Dog* pDog = mutationDog();

    Не удержался, чтоб не запостить. Сами знаете откуда.

    LispGovno, 17 Сентября 2012

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

    +41

    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
    int sheeps(int pole[10][10])
    {
        int i,j,f,k,r;
        int rand_chislo, rand_chislo1, ts,s; 
      
          srand(time(NULL));      
         for (i=0;i<10;i++)   
          for (j=0;j<10;j++)
          pole [i][j]=0;  
         do{ f=0;                                
            rand_chislo = 0 + rand() %10;
            rand_chislo1= 0 + rand() %10;        
            ts = 1+rand()%4;        
              if (ts==1) {for(i=0;i<3;i++) if(rand_chislo==i)f=1;}
             if (ts==2)  {for(i=7;i<10;i++) if(rand_chislo==i)f=1;}                          
              if (ts==3) {for(i=0;i<3;i++) if(rand_chislo1==i)f=1;}
             if (ts==4)  {for(i=7;i<10;i++) if(rand_chislo1==i)f=1;}       
            }
           while (f==1);
            switch (ts){
              case 1: pole[rand_chislo][rand_chislo1]=1; pole[rand_chislo-1][rand_chislo1]=1;
                      pole[rand_chislo-2][rand_chislo1]=1;pole[rand_chislo-3][rand_chislo1]=1; break;
               case 2: pole[rand_chislo][rand_chislo1]=1; pole[rand_chislo+1][rand_chislo1]=1; 
                       pole[rand_chislo+2][rand_chislo1]=1;pole[rand_chislo+3][rand_chislo1]=1; break;
             case 3: pole[rand_chislo][rand_chislo1]=1; pole[rand_chislo][rand_chislo1-1]=1;
                     pole[rand_chislo][rand_chislo1-2]=1;pole[rand_chislo][rand_chislo1-3]=1;break;
              case 4: pole[rand_chislo][rand_chislo1]=1; pole[rand_chislo][rand_chislo1+1]=1;
                      pole[rand_chislo][rand_chislo1+2]=1;pole[rand_chislo][rand_chislo1+3]=1; break; }
         
        for (k=0;k<3;k++)                                      
         {
           do{ f=0;
            rand_chislo = 0 + rand() %10;
            rand_chislo1= 0 + rand() %10;       
            ts = 1+rand()%4;       
              if (ts==1)  {if(rand_chislo!=0){ for (i=rand_chislo-2;i<rand_chislo+2;i++)
                                          for (j=rand_chislo1-1;j<=rand_chislo1+1;j++)
                                            {if (pole[i][j]!=0){f=1;}}}else f=1; }
             if (ts==2)  {if (rand_chislo!=9)  {  for (i=rand_chislo-1;i<=rand_chislo+2;i++)
                                              for (j=rand_chislo1-1;j<=rand_chislo1+1;j++)
                                              { if (pole[i][j]!=0){ f=1;}}}else f=1;  }                            
              if (ts==3) { if (rand_chislo1!=0) {   for (i=rand_chislo-1;i<=rand_chislo+1;i++)
                                                for (j=rand_chislo1-2;j<=rand_chislo1+1;j++)
                                                { if (pole[i][j]!=0){ f=1;}}}else f=1;  } 
             if (ts==4) { if (rand_chislo1!=9) {   for (i=rand_chislo-1;i<=rand_chislo+1;i++)
                                                for (j=rand_chislo1-1;j<=rand_chislo1+2;j++)
                                                { if (pole[i][j]!=0){ f=1;}}} 
                                                else f=1;   }                                  
            }
           while (f==1);
            switch (ts){
              case 1: pole[rand_chislo][rand_chislo1]=1; pole[rand_chislo-1][rand_chislo1]=1; break;
              case 2: pole[rand_chislo][rand_chislo1]=1; pole[rand_chislo+1][rand_chislo1]=1; break;
              case 3: pole[rand_chislo][rand_chislo1]=1; pole[rand_chislo][rand_chislo1-1]=1;break;
              case 4: pole[rand_chislo][rand_chislo1]=1; pole[rand_chislo][rand_chislo1+1]=1; break; }  
         }    
         for (k=0;k<2;k++)                                  
         {
           do{ f=0;
            rand_chislo = 0 + rand() %10;
            rand_chislo1= 0 + rand() %10;
          
     /*зесь еще 2 таких же while (if==1) и for k<3 и k<4 */
    
    return pole[10][10];
    }

    курсовик первокурсника "морской бой". функция расстановки кораблей

    equilibrium, 17 Сентября 2012

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

    +137

    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
    {- Haskell -}
    bruteforceGeneratorWithEasySimplication :: Description d => d -> [StandartTable]
    bruteforceGeneratorWithEasySimplication description =
        let width = size_h description; height = size_v description; vHeader = headerV description in
            do
                table <- genListBasedOn (map lineVariants vHeader)
                return (ST table)
        where
            lineVariants :: [Int] -> [[Bool]]
            lineVariants headerLine = let
                всё_я_задолбался_однако = True -- K.O.
                количество_цельных_блоков = length headerLine
                число_промежутков = количество_цельных_блоков - 1
                число_свободных_пробелов_которые_нам_нужно_распихать_между_цельными_блоками = ширина_поля - суммарная_длина_цельных_блоков
                ширина_поля = size_h description
                суммарная_длина_цельных_блоков = sum headerLine
                
                возможная_строка_использующая :: [Int] -> [Bool]
                возможная_строка_использующая разбиение = replicate (head разбиение) False ++ 
                    concat (zipWith (\x y -> replicate y True ++ replicate x False) (tail разбиение) headerLine)
                
                и = and
                по = undefined
                
                in do
                    разбиение <- получить_разбиение_для_строки по (число_свободных_пробелов_которые_нам_нужно_распихать_между_цельными_блоками) и (число_промежутков)
                    return (возможная_строка_использующая разбиение :: [Bool])
    
    получить_разбиение_для_строки по числу_свободных_элементов и числу_промежутков = do ...

    Из раннего.

    По-видимому, задолбался писать на тарабарщине, захотелось выражаться родными русскими словами.

    Jean-Esther, 16 Сентября 2012

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

    +156

    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
    @show[]
    $cars[^table::sql{select * from count_cars order by sortir}]
    <script>
    var CarsDescription = new Array()^;
    $counter(1)
    ^cars.menu{
    CarsDescription[$counter] = '$cars.characteristic'^;
     ^counter.inc[]
    }
    </script> 
    <script type="text/javascript" src="/cars_calc/script.js"></script>
    <link rel="stylesheet" type="text/css" href="/cars_calc/style.css">
    <section class="page">
       <section class="scheme">
        <span id="cr" class="cr"></span>
            $cars_count(16)      
            ^for[car](1;$cars_count){ 
        <span id="select-car-$carId" class="car-$carId">$car</span>
            }
     </section>

    Код из одной веб-студии. Смысл в том что в javascript должен быть передан массив из базы данных, вместо того чтобы послать пакет с нужными данными в формате json (или любом другом) и обработать его, в исходный файл html-разметки (тут как видно и javascript вставлен) добавили код Parser'а (для тех кто-незнаком это язык для быстрой разработки веб-сайтов от Лебедева, что-то вроде простой альтернативы php), который перед тем как отдать пользователю страницу, обрабатывает её и вставляет в нужные места, нужные данные. В общем сами оценивайте этот маразм...

    Kerny, 16 Сентября 2012

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

    +11

    1. 1
    clEnqueueReleaseGLObjects(queue, objects.size(), objects.data(), 9, NULL, NULL);

    В целом ничего страшного, но почему на клавиатуре девятка так рядом с нулём?

    bazhenovc, 15 Сентября 2012

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

    +114

    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
    #include <stdio.h>
    /* Программа выводит ASCII-коды введённых символов */
    int main()
    {
        int a[255];
        int i;
        for (i = 0; i < 256; i++) {
            a[i] = i;
        }
        int c;
        while ((c = getchar()) != EOF) {
            if (c != '\n')
                printf("%d\n", a[c]);
        }
        return 0;
    }

    vistefan, 15 Сентября 2012

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

    +132

    1. 1
    2. 2
    3. 3
    4. 4
    <form method="POST" action="/registr/detail.php?ID=114022261">
        <input type="submit" value="Да" name="YES">
        <input type="submit" value="Нет" name="NO">
    </form>

    Таким образом на mkrf.ru посетитель подтвердить своё желание продолжить просмотр каждый раз, когда хочет почитать карточку фильма "с ограничениями".

    nsauk, 15 Сентября 2012

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

    +43

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    <?php
    
    	function monthName($monthNumber) {
    
    		echo date('F', strtotime('first day of '.($monthNumber - date('n')).' month'));
    		
    	}
    	
    	monthName(10);
    	
    ?>

    Знаю, что не говнокод, но решил запостить - поделиться, ибо встречал тут много говнокода относительно подобного алгоритма получения названия месяца по порядковому номеру онного и много различных вариантов "неговнокода" в коментариях, но именно такой "пыхдатой" реализации не видел - впечатлило, хороший "антиВелосипед" :)

    killro0000, 15 Сентября 2012

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

    −105

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    if [ `which which` ]; then
      ...
    else
      ...
    fi

    gongled, 14 Сентября 2012

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