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

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

    +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
    public Random abstract_logic = new Random();
    ...
            private int ComplexFunctionToDetermineTheNumberOfResults(ObservableCollection<Result> rs)
            {
                int a = 0;
                for (int i = 0; i < rs.Count; i++)
                {
                    a += rs[i].Value;
                }
                double d = a / Math.PI;
                d = Math.Cos(d) * Math.Sin(a) * (Math.Cos(Math.PI) + 1);
                return abstract_logic.Next((int)d + 3) + 3;
            }

    Лаба 2.
    Наформашлепствовал 40+ файлов (Сплошной говнокод), в итоге должна получится система тестирования. В конце данной функцией определяю количество выводимых результатов.

    maksim_ovcharik, 22 Декабря 2013

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

    +28

    1. 1
    QVector<double*>*** ElemBoundCond = tbc->getElementsBC();

    Abbath, 06 Декабря 2013

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

    +16

    1. 1
    2. 2
    3. 3
    function<future<int> (int)> f = [](int a){ cout << a << '\n'; return mreturn(a + 6); };
    int a = (mreturn(5) >>= f).get();
    cout << a;

    HaskellGovno, 06 Декабря 2013

    Комментарии (14)
  5. Си / Говнокод #14097

    +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
    int memcmp (const void* v1, const void* v2, size_t n)
    {
       uint32_t *s1;
       uint32_t *s2;
       size_t  i;
    
       s1 = (uint32_t*) v1;
       s2 = (uint32_t*) v2;
    
       for (i = 0; i < n; i++) {
                    if (*s1 != *s2) {
                            return *(const uint32_t *)s1 >
                                   *(const uint32_t *)s2 ? 1 : -1;
                    }
                    s1++;
                    s2++;
            }
       return 0;
    }

    Реализация memcmp в библиотеке одной малоизвестной "учебной" ОС реального времени. Учебной в том смысле, что по этой системе разве что доклады, презентации и статьи делали, где-то реально она вряд ли использовалась.
    Для интересующихся http://pok.safety-critical.net/

    WGH, 14 Ноября 2013

    Комментарии (14)
  6. Java / Говнокод #14049

    +72

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    9. 9
    String isFeatureEnabled = object.get("featureEnabledParam");
    boolean featureEnabled = app.isFeatureEnabled();
    if (Boolean.parseBoolean(isFeatureEnabled) && !featureEnabled) {
        return false;
    }
    if (!Boolean.parseBoolean(isFeatureEnabled) && featureEnabled)
    {
        return false;
    }

    myzone, 22 Октября 2013

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

    +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
    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
    int DataBase::garbageCollector(string filename){ 
        fstream from(filename.c_str());
        fstream from0((filename+".index").c_str());
        Index x;
        Data d;
        char *a/*,*b*/;
        int oldpos = 0 ;
        bool done = false;
        from.seekg(0,ios::end);
        int dbend = static_cast<int>(from.tellp());
        from0.seekg(0,ios::end);
        int indexend = static_cast<int>(from0.tellp());
        if(dbend == BlockSize || indexend == IndexSize){
    	from.close();
    	from0.close();
    	return 0;
        }
        from.seekg(0,ios::beg);
        from0.seekg(0,ios::beg);
        while(true){ 
            from0 >> x;
            if(from0.eof())break;
            if(!x.Num()){ 
                int count = dbend - x.Pointer() - BlockSize;
                int count0 = indexend - (static_cast<int>(from0.tellp())+1);
                from.seekg(x.Pointer()+BlockSize);
                a = new char[count]; 
                from.read(a,count);
                from.seekp(x.Pointer());
                from.write(a,count);
                delete a;
                a = new char[count0];
                from0.seekp(1,ios::cur);
                int test = from0.tellp();
                from0.read(a,count0);
                from0.clear();
                from0.seekp(indexend - count0 - IndexSize,ios::beg);
                test = from0.tellp();
                from0.write(a,count0);
                test = from0.tellp();
                delete a;
                ofstream to("tmp.base",ios::trunc),to0("tmp.index",ios::trunc);
                a = new char[dbend - BlockSize];
                from.seekg(0,ios::beg);
                from.read(a,dbend - BlockSize);
                to.write(a,dbend - BlockSize);
                delete a;
                a = new char[indexend - IndexSize];
                from0.seekg(0,ios::beg);
                test = from0.tellp();
                from0.read(a,indexend - IndexSize);
                to0.write(a,indexend - IndexSize);
                delete a;
                from.close();
                from0.close();
                if(remove(filename.c_str()) || rename("tmp.base",filename.c_str())) return -1;
                if(remove((filename+".index").c_str()) || rename("tmp.index",(filename+".index").c_str())) return -1;
                oldpos = indexend - count0 - IndexSize;
                done = true;
                break;
            }
        }
        if(done){
            from0.open((filename+".index").c_str());
            while(true){ 
                from0 >> x;
                if(from0.eof())break;
                if(x.Pointer() > static_cast<unsigned>((oldpos/23)*BlockSize) ){ 
                    x.Pointer(x.Pointer()-BlockSize);
                    from0.seekp(-(IndexSize-1),ios::cur);
                    from0 << x;
                    int test = from0.tellp();
                }
                else{ 
                    from0.seekp(-(IndexSize-1),ios::cur);
                    from0 << x;
                    int test = from0.tellp();
                    from0.clear();
                }
            }
        }
        return 0;
    }

    Собираем пустые блоки

    Abbath, 15 Октября 2013

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

    +127

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    <Grid x:Name="LayoutRoot" >
    	<Grid.ColumnDefinitions>
    		<ColumnDefinition />
    	</Grid.ColumnDefinitions>
    	<Grid.RowDefinitions>
    		<RowDefinition />
    	</Grid.RowDefinitions>
    	
    	// .. разные контролы
    	
    </Grid>

    Это тоже кусочек XAML (WPF)

    Smekalisty, 27 Сентября 2013

    Комментарии (14)
  9. JavaScript / Говнокод #13655

    +141

    1. 1
    for (; b < d; b++)

    subj

    Stealth, 23 Августа 2013

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

    +6

    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
    #include <iostream>
    
    using std::cout;
    using std::endl;
    
    auto power(double x, int n)-> double*;
    
    int main()
    {
    	void * c = power(5,2);
    
    	std::cout << *(double*)c << std::endl;
    
    	return 0;
    }
    
    auto power(double x, int n)-> double* 
    { 
    	double* result(new double(1.0));
    	for(int i = 1; i <= n; i++)
    	*result *= x;
    	return result;
    }

    taburetka, 21 Августа 2013

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

    +5

    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
    #include <iostream>
     
    using namespace std;
     
    void f(void){cout<<"f"<<endl;}
    void f1(void){cout<<"f1"<<endl;}
     
    bool secondIfIsTryed(){cout<<"secondIfIsTryed"<<endl;return true;}
     
    #define asserts(Condition) {cout<<"Assert"<<endl;}
     
    int main() {
        if(true)
            if(secondIfIsTryed() && false)
                f();
            else
                f1();
        
        if(true)
            if(secondIfIsTryed() && false)
                asserts(true)
            else
                f1();
        return 0;
    }

    Помните того вечно сомневающегося знакомого, тест крестов, написанный которым я недавно приводил?
    http://ideone.com/9Q61D1
    В этот раз под его глуповатый, но пытливый взгляд попал макрос ассерта. Написан он конечно не так, как в этом тесте, но имеет код вида:

    #define asserts(Condition) {/*...*/}


    В итоге он сделал умозаключение: "Вокруг меня собрались голубцы" и надулся.

    LispGovno, 19 Июля 2013

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