1. C++ / Говнокод #4427

    +168

    1. 1
    2. 2
    3. 3
    4. 4
    #define loopv(v)    for(int i = 0; i<(v).length(); i++)
    #define loopvj(v)   for(int j = 0; j<(v).length(); j++)
    #define loopvk(v)   for(int k = 0; k<(v).length(); k++)
    #define loopvrev(v) for(int i = (v).length()-1; i>=0; i--)

    Может я чего недопонимаю?
    Это из Cube 2: Sauerbraten

    Werdn, 23 Октября 2010

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

    +149

    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
    matrix[0][0]=3;
    matrix[0][1]=1;
    matrix[0][2]=1;
    matrix[0][3]=6;
    matrix[1][0]=0;
    matrix[1][1]=-2;
    matrix[1][2]=1;
    matrix[1][3]=-3;
    matrix[2][0]=2;
    matrix[2][1]=-1;
    matrix[2][2]=4;
    matrix[2][3]=-1;
    
    cout<<"MATRIX:"<<endl;
    for (i=0;i<4;i++) {
            cout<<matrix[0][i]<<" ";
               if (i==3) {
                   cout<<" "<<endl;
                       for (i=0;i<4;i++) {
                              cout<<matrix[1][i]<<" ";
                                if (i==3) {
                                    cout<<" "<<endl;
                                        for (i=0;i<4;i++) {
                                            cout<<matrix[2][i]<<" ";};};};};};

    Вывод двумерного массива :)

    petro2033, 20 Октября 2010

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

    +164

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    srand(time(0));
    for (i = 0; i < 10000; i++) {
        sprintf(qtrc, "/tmp/%010d", rand());
        if (!mkdir(qtrc, 0700))
            goto okay;
    }
    logPanic("Cannot create $HOME\n");
    okay:

    Исходники KDM

    proDOOMman, 17 Октября 2010

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

    +160

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    std::string ScriptInfo::GetDebugInfo() const
    {
        char sz[256];
        sprintf(sz, "%s ('%s' script id: %u)", GetScriptCommandName(command).c_str(), GetScriptsTableNameByType(type).c_str(), id);
        return std::string(sz);
    }

    Может, не совсем говнокод, но меня от подобного коробит.

    Oops, 17 Октября 2010

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

    +162

    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
    /*
        Макрос генерирует внутренности функции-заглушки OpenGL.
    */
    #define BWT_DECLARE_OPENGL_PROC_IMPL(PROC, PROC_TYPE, ...)                                  \
        static PROC_TYPE _##PROC = 0;                                                           \
                                                                                                \
        if (_##PROC)                                                                            \
            return _##PROC(__VA_ARGS__);                                                        \
        else                                                                                    \
        {                                                                                       \
            _##PROC = TryToGetProcAddress<PROC_TYPE>(#PROC);    return _##PROC(__VA_ARGS__);    \
        }
    
    /*
        Функция получает адрес функции, или возбуждает исключение, если адрес получить не удалось.
    */
    template<typename proc_type>
    proc_type TryToGetProcAddress(const char *proc_name) throw(error_type<VIDEO>)
    {
        proc_type address = reinterpret_cast<proc_type>(::SDL_GL_GetProcAddress(proc_name));
    
        if (!address)
            BWT_THROW_VIDEO_ERROR(UNDEFINED_ERROR, "OpenGL version does not supported");
    
        return address;
    }
    
    GLAPI void APIENTRY glCullFace (GLenum mode)
    {
        BWT_DECLARE_OPENGL_PROC_IMPL(glCullFace, PFNGLCULLFACEPROC, mode);
    }
    
    ...

    ZltCity, 15 Октября 2010

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

    +160

    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 <iostream>
    using namespace std;
    int main(){
    char b,a[1001];
    int i, c=0;
    cin >> b;
    for(i=1; i<=1000; i++)
      cin >> a[i];
    for( i=1; i<=1000; i++)
      if(a[i]=='b') c++;
    
    cout <<c<<" "<<b<<" characters in ";
    for(i=1; i<=1000; i++)
      cout << a[i];
    return 0;
    }  //помогите найти ошибку

    Источник - http://tinyurl.com/26n9df5

    Skiv, 12 Октября 2010

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

    +154

    1. 1
    2. 2
    3. 3
    String boo =  value[i]/*.ConvertTo<String>()*/;
    std::string boovalue(boo.Value());
    st.bind(1+i, boovalue.c_str());

    hamsta, 11 Октября 2010

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

    +164

    1. 1
    2. 2
    #define MERGE(X,Y) X##Y
    typedef unsigned MERGE(ch,ar)	byte;

    sermp, 11 Октября 2010

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

    +157

    1. 1
    2. 2
    3. 3
    4. 4
    if ( условие )                                                                                                                                                                                                                                                                                                                                             ;                 
    {
     //что-либо сделать
    };

    //"счастливой отладки" v.2.0
    отгреб в собственном-же коде)))))

    Denjs, 08 Октября 2010

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

    +191

    1. 1
    2. 2
    3. 3
    4. 4
    // I am not responsible of this code.
    // They made me write it, against my will.
    
    double penetration;

    http://community.livejournal.com/programmers_fun/65300.html

    wecanstoptrain, 20 Сентября 2010

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