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

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

    +19

    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
    #include "stdafx.h"
    #include "stdio.h"
    #include "stdlib.h"
    #include "locale.h"
    int gl(char ch);
    int main()
    { char a;
    setlocale(LC_ALL, "rus");
    printf("Введите букву\n");
    scanf_s("%c", &a);
    if (gl(a)==1)
    printf("Гласная", a);
    else
    printf("Не гласная", a);
    printf("%c", gl(a));
    system("pause");
    }
    int gl(char ch)
    { char m[18]={'У', 'Е', 'А', 'О', 'Э',
    'Я', 'И', 'Ю', 'Ё',
    'у', 'е', 'а', 'о', 'э', 'я', 'и', 'ю', 'ё'};
    int N=0;
    setlocale(LC_ALL, "rus");
    for (int i=0; i<18; i++)
    if (m[i]==ch) N++;
    if (N==1)
    return 1;
    else return 0;
    }

    Вопрос блондинки, на одном из прогерских форумов. Для информативности добавлю её вопрос:

    Написать функцию, которая возвращает произведение элементов одномерного массива.
    Ошибок нет. Всё время возвращает значение "не гласная" при вводе любых и согласных, и гласных букв. В чём ошибка? Вроде правильно функция значение возвращает...?

    hromjo, 09 Апреля 2013

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

    −96

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    int arrayCount = [itemArray count];
    if( currentHeight < 10000 ) {
        currentItemType = random() % arrayCount;
    } else if( currentHeight < 50000 ) {
        currentItemType = random() % arrayCount;
    } else if( currentHeight < 100000 ) {
        currentItemType = random() % arrayCount;
    } else {
        currentItemType = random() % arrayCount;
    }

    Чем выше горы - тем рандомней сборы.

    NAlexN, 16 Марта 2013

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

    −88

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    // поднимаем и опускаем панель голосования при входящем вызове
            for (ASSlideView* slideView in self.view.subviews)
                if ([slideView isKindOfClass:[ASSlideView class]])
                    for (UIScrollView* scroll in slideView.subviews)
                        if ([scroll isKindOfClass:[UIScrollView class]])
                            for (UIView* view in scroll.subviews)
                                if ([view isKindOfClass:[UIView class]])
                                    for (KVRateView* rateView in view.subviews)
                                        if ([rateView isKindOfClass:[KVRateView class]]){
                                            [rateView setFrame:CGRectMake(rateView.frame.origin.x, [[UIScreen mainScreen] bounds].size.height - 140 - [[UIApplication sharedApplication]statusBarFrame].size.height, rateView.frame.size.width, rateView.frame.size.height)];
                                            break;
                                        }

    No comments

    mas_an, 13 Февраля 2013

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

    +170

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    9. 9
    function onKeyDown() {
            var key_f5 = 116; // 116 = F5 
    
            if (key_f5 == event.keyCode) {
              event.keyCode = 27;
    
              return false;
            }
          }

    Запрещаем обновление страницы по F5.

    Ccik, 10 Января 2013

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

    +23

    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
    struct S* gpS;
    
    struct S
    {
       // this class has no user-defined default ctor
       void *operator new (size_t size, void*p, int i)
       {
          ((S*)p)->i = i;   // ordinarily, should not initialize
                            // memory contents inside placement new
          return p;
       }
       int i;
    };

    Код с сайта майкрософт.

    LispGovno, 09 Января 2013

    Комментарии (17)
  7. PHP / Говнокод #12294

    +58

    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
    // Released Under Affero General Public License, Version 3 (AGPL3)
    // Author: [email protected]
    
    $result = "TRUE";
    
    $testable_string = strtolower($string_to_test);
    $testable_string_length = strlen($string_to_test);
    
    for($i_string = 0; $i_string < $testable_string_length; $i_string++)
    {
        $current_value_to_test = $testable_string[$i_string];
       
        if(    ($current_value_to_test != "0")        &&
            ($current_value_to_test != "1")        &&
            ($current_value_to_test != "2")        &&
            ($current_value_to_test != "3")        &&
            ($current_value_to_test != "4")        &&
            ($current_value_to_test != "5")        &&
            ($current_value_to_test != "6")        &&
            ($current_value_to_test != "7")        &&
            ($current_value_to_test != "8")        &&
            ($current_value_to_test != "9")        &&
            ($current_value_to_test != "a")        &&
            ($current_value_to_test != "b")        &&
            ($current_value_to_test != "c")        &&
            ($current_value_to_test != "d")        &&
            ($current_value_to_test != "e")        &&
            ($current_value_to_test != "f")        )
        {
            $result = "FALSE";
            $i_string = $testable_string_length;
        }
    }

    Смахивает на баян, но тем не менее.
    http://php.net/manual/ru/function.is-numeric.php, из комментов.

    RaZeR, 14 Декабря 2012

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

    +50

    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
    function StringForCountryInt($countryInt)
    	{
    		switch ($countryInt)
    		{
    			case "1" : return 'Afghanistan'; break;
                case "2" : return 'Albania'; break;
                case "3" : return 'Algeria'; break;
                case "4" : return 'American Samoa'; break;
                case "5" : return 'Andorra'; break;
                case "6" : return 'Angola'; break;
                case "7" : return 'Anguilla'; break;
                case "8" : return 'Antarctica'; break;
    //          ....
    //          ....
    //          ....
                 case "239" : return 'Zimbabwe'; break;
    		}
    	}

    MODx, evolution. Сниппет WebLoginPE.
    В базе сохраняет ID страну, в классе вот такой метод для обратного преобразования :)

    MaXL, 04 Декабря 2012

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

    +51

    1. 1
    2. 2
    3. 3
    4. 4
    $needMoreDataWM = ($exchange->getSumTo()->getCurrency()->getSystem()->getModule() == 'WebMoney' || $exchange->getSumFrom()->getCurrency()->getSystem()->getModule() == 'WebMoney') || $this->getRequest()->request->get('user_wmid');
    $needMoreDataWM = $needMoreDataWM && !$user->getWmid();
    $needMoreDataBank = ($exchange->getSumTo()->getCurrency()->getSystem()->getClass() == 'bank') && !$user->getVat() || $this->getRequest()->request->get('user_vat');
    $needMoreData = $needMoreDataBank || $needMoreDataWM || !($user->getFullname() && $user->getPassport()) || $this->getRequest()->request->get('user_fullname') || $this->getRequest()->request->get('user_passport');

    А что поделаешь, Doctrine принуждает

    nick4fake, 28 Ноября 2012

    Комментарии (17)
  10. Си / Говнокод #12197

    +133

    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
    #include<stdio.h>
    #include<math.h>
     
    int main()
    {
    long long a1,a2,a3,a4,t,p,l,m1,m,d1,d2,d3,d4,c1,c2,c3,c4,n,r;
    double po;
     
    m=1000000006;
    scanf("%lld",&t);
    while(t--)
         {scanf("%lld",&n);
         a1=1;a2=1;a3=1;a4=0;
         d1=1;d2=0;d3=0;d4=1;
         
         p=n-2;
    while(p>0)
         {    if(p%2!=0)
            { c1=((d1*a1)%m+(d3*a3)%m);
              c2=((d1*a2)%m+(d2*a4)%m);
              c3=((d3*a1)%m+(d4*a3)%m);
              c4=((d3*a2)%m+(d4*a4)%m);
              d1=c1;d2=c2;d3=c3;d4=c4;
            }
              c1=((a1*a1)%m+(a2*a3)%m);
              c2=((a1*a2)%m+(a2*a4)%m);
              c3=((a3*a1)%m+(a4*a3)%m);
              c4=((a3*a2)%m+(a4*a4)%m);
              a1=c1;a2=c2;a3=c3;a4=c4;
              p=p/2;
         }
     l=((d1*1)%m+(d2*1)%m)%m;m1=((d3*1)%m+(d4*1)%m)%m;
     
    po=pow(2,l);
    r=llrintl(po)%(m+1);
     
     
    printf("%lld\n",r);
    }
    return 0;
       }

    Fai, 26 Ноября 2012

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

    +124

    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
    Сайт ЦИК Украины, нынешние выборы народных депутатов. 
    http://cvk.gov.ua/vnd2012/wp300pt001f01=900.html
    Говно везде - html, css, дизайн, юзабилити. 
    
    Для начала цитаты из html-кода страницы. В шапке мы видим 
    заголовок "XHTML 1.0 Transitional", а в коде - конструкции 
    в стиле 90-х годов, например:
    
    <IMG src="img2012/bar-blue1.jpg" WIDTH=" 1" HEIGHT=20>
    
    <table class=t1 cellspacing=0><tr>
        <td width="50%" class="td2"><font class="f3"> © WWW ІАС "Вибори 
            народних депутатів України"
        <td align="right" class="td2"> 
    </table>
    
    <td class=td10 align=center><font color="maroon">2</font>
    <td class=td2><A class=a1 href="wp302pt001f01=900pf7171=52.html">
    політична партія Всеукраїнське об’єднання "Батьківщина"</A></td>
    
    В стилях тоже все в порядке, товарищи проявили 
    отличное знание спецификаций:
    ... height=14px; ...
    ... background-color: 666699; ...
    ... text-decoration: non ...
    ... background-color : none; ...
    ... valign: center; ...
    
    Про отсутствие смысла я даже не говорю. 
    Вот, например, такой перл:
    FONT.F1 {color: black; font-family:Arial;font-size: 14pt}

    Сайт ЦИК Украины. Не сомневаюсь, что ООО "НПП "Медирент"" и ООО "НПП "Проком" получили за свою работу сотни нефти.

    P.S. Плохо, что в самом говнокоде нельзя применять форматирование bb-тегами, для кучи было бы полезно.

    ZX_Spectrum, 31 Октября 2012

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