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

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

    +16

    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
    /*
        Дана последовательность, содержащая от 2 до 50 слов, в каждом из которых от 1 до 8 строчных
        латинских букв; между соседними словами - не менее одного пробела, за последним словом - точка.
        Напечатать те слова последовательности, которые отличны от первого слова и
        удовлетворяют следующему свойству: в слове нет повторяющихся букв.
    */
    #include <iostream>
    #include <cstring>
    using namespace std;
    
    void strComparsion(const char *str1, const char *str2, const int beginStr2, const int endStr2);
    int main()
    {
    
        char arrWord[50*8+50+1] = "spros na java programmistov"
                                                " rastet i v etom vinovat chertov android.";
        int counterSpace = 0; //Счетчик пробелов
        char strOneBuffer[9]; //Массив для первого слова
    
        cout << "Na vhode: \n" << arrWord << endl;
        cout << "Na vyhode: \n";
    
        //Копируем первое слов  в отдельный массив
        for(int i = 0; arrWord[i-2] != ' ';i++)
        {
            strOneBuffer[i] = arrWord[i];
            if(arrWord[i] == ' ')
            {
                strOneBuffer[i] = '\0';
                counterSpace = i;
            }
        }
    
        for(int i = counterSpace + 1, j = counterSpace + 1; arrWord[i] != '\0' ; i++)
            if(arrWord[i] == ' ' || arrWord[i] =='.')
            {
               strComparsion(strOneBuffer, arrWord, j, i);
               j = i +1;
            }
    
        return 0;
    }
    void strComparsion(const char *str1, const char *str2, const int beginStr2, const int endStr2)
    {
        //Флаги
        int countSymbol = 0;
        int repeatSymbol = 0;
    
        //Сравниваем слова с первым словом
        if( strlen(str1) == endStr2 - beginStr2 )
            for(int i = 0, j = beginStr2; j < endStr2; i++, j++)
                if(str2[j] == str1[i])
                    countSymbol++;
    
        //Ищем повторяющийся буквы в слове
        for(int i = beginStr2; i < endStr2; i++)
            for(int j = beginStr2; j < endStr2; j++)
            {
                if(i == j)
                    continue;
                if(str2[i] == str2[j])
                    repeatSymbol++;
            }
    
        //Выводим слово по требуеиым критериям
        if(countSymbol < strlen(str1) && repeatSymbol == 0)
            for(int i = beginStr2; i < endStr2; i++)
            {
                cout << str2[i];
                if(i == endStr2 - 1)
                    cout << " ";
            }
    }

    Это я писал после 6 месяцев изучения кодинга

    ConstantineVL, 29 Июня 2014

    Комментарии (51)
  3. JavaScript / Говнокод #13871

    +149

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    function refreshPaymentStatus() {
    }
    
    refreshPaymentStatusJob();
    
    function refreshPaymentStatusJob() {
        setInterval("refreshPaymentStatus()", 10000);
    }

    Бесят люди которые, будучи обмануты кажущейся простотой JS, пишут такие конструкции "по привычке". Job он, @#$%, завёл. А Scheduler, интересно, где забыл? А SchedulerManager? А SchedulerManagerFactory? Зато не забыл передать строкой первый аргумент в setInterval, молодец.

    madhead, 30 Сентября 2013

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

    +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
    double vvod (double a1, double a2, double a3) {
     
    // a1=a a2=b a3=c
     
    	cout<<"Введите значение коэфицента a: ";
    	cin>>a1;
    	cout<<endl;
    	cout<<"Введите значение коэфицента b: ";
    	cin>>a2;
    	cout<<endl;
    	cout<<"Введите значение коэфицента c: ";
    	cin>>a3;
    	cout<<endl;
    	return (a1);
    	return (a2);
    	return (a3);
    }

    Оказывается в С++ можно возвращать 3 значения из функции
    http://ideone.com/tGWRpl - полная версия.

    pabloid, 05 Сентября 2013

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

    +8

    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
    #include <pthread.h>
    template<class T = long long>
    class AtomicCounter
    {
        public:
            explicit AtomicCounter( T value = 0 ): _count( value ) { pthread_spin_init( &_lock, PTHREAD_PROCESS_PRIVATE );};
            ~AtomicCounter()  { pthread_spin_destroy( &_lock );    };
    
            T operator++(int) volatile {  return interlockFetchAndAdd( 1 );      };
            T operator--(int) volatile {  return interlockFetchAndAdd( -1 );     };
            T operator() ()   volatile {  return interlockFetchAndAdd( 0 );      }
    
        private:
            volatile T    _count;
            pthread_spinlock_t _lock;
    
            T interlockFetchAndAdd( int delta ) volatile
            {
                T x = 0;
                pthread_spin_lock( &_lock );
                x = _count;
                _count += delta;
                pthread_spin_unlock(&_lock);
                return x;
            }
    };

    Принцип наименьшего удивления, говорите

    roman-kashitsyn, 26 Июля 2013

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

    +25

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    bool Channel::applyPreprocessorSettings()
    {
    	if (captureDeviceID_.empty() || !isSafeToChangeSettingsNow())
    		CHANNEL_LOG("deferring applyPreprocessorSettings()");
    		needApplyPreprocessorSettings_ = true;
    		return false;
    
    	// ... (куча кода)
    	
    	return true;
    }

    Никогда - слышите, НИКОГДА! - не пишите на C++ одновременно с питоном.

    Kirinyale, 09 Апреля 2013

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

    +19

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    struct BufInfo 
    {
    	const tbal::Bitmap &src, &dst;
    	int y1, y2;
    	BufInfo (const tbal::Bitmap &scr, const tbal::Bitmap &dst, int y1, int y2) : src(src), dst(dst), y1(y1), y2(y2) {}
    };

    Как можно проебать час жизни...

    TarasB, 20 Марта 2013

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

    +11

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    typedef void Start1(void);
    struct Kernel
    {
        Start1 Start;
    } kernel;
     
    void Kernel::Start(void)
    {
     
    }

    Как всегда оттуда.

    LispGovno, 06 Ноября 2012

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

    +21

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    #include <stdio.h>
    #include <stdlib.h>
    #include <math.h>
    
    int main()
    {
        unsigned int input[65536];
        int counter=0;
        while(scanf("%u", &(input[counter++])) != EOF);
        while (counter-- > 0) printf("%.4f\n", sqrt((double)(input[counter])));
        return 0;
    }

    Реализация задачи http://acm.timus.ru/problem.aspx?space=1&num=1001

    kganker, 19 Октября 2012

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

    +57

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    if($atributId){
          $sql = "UPDATE directory_atributes SET name = '$newName' WHERE id = $atributId LIMIT 1";
          $db-> Query($sql);
          die();
     } else{
          die();
     }

    Депрессивное программирование. В любом случае ты умрёшь.

    somnambulism, 01 Октября 2012

    Комментарии (51)
  11. C# / Говнокод #9855

    +126

    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
    double fact(int value)
            {
                switch (value)
                {
                    case 0:
                        return 1;
                        break;
                    case 1:
                        return 1;
                        break;
                    default:
                        return value * fact(value - 1);
                        break;
                }
            }

    Вычисление факториала

    zzANDREYzz, 04 Апреля 2012

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