1. 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)
  2. C++ / Говнокод #11777

    +11

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

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

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

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

    +28

    1. 1
    2. 2
    std::size_t _;
    std:size_t __;

    http://ideone.com/Ie1AY

    HaskellGovno, 13 Сентября 2012

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

    +20

    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
    #include <iostream>
    #include <string>
    #include <stdio.h>
    #include <time.h>
    
    int main()
    {
        time_t now = time(0);
        struct tm  tstruct = *localtime(&now);
    
        if (tstruct.tm_yday & 0xff) {   
           std::cout << "Pasony, segodnja den' programmista!"<< std::endl;
        } else {
            /*Syscall platform dependent implementation */
            //KeepCoding();
        }
        
    return 0;
    }

    ВНЕЗАПНО: http://tinyurl.com/c8kkxl8

    sayidandrtfm, 12 Сентября 2012

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

    +35

    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
    // стоит простая задача: удалить все узлы из списка
    // чувак думает, как же ему это реализовать через задницу?
    // и получилось же!
    
    if (link * root = list.get_root()) {
        link * next;
        do {
            next = root->next();
            list.remove(next);
        } while (root = next);
    }
    
    // неужели нельзя вот так, по-простому?
    
    link * node = list.get_root();
    while (node) {
        link * next = node->next();
        list.remove(node);
        node = next;
    }

    alexzak, 11 Сентября 2012

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

    +22

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    string toString( int i ) {
    	stringstream s;
    	s << i;
    	return s.str();
    }

    Наткнулся на эту функцию в одном из своих старых проектом.

    Fai, 11 Сентября 2012

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

    +29

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    string input;
    string output;
     
    input = "C:\\bla.txt\\";          //"Bla.txt" is the file to copy
    output = "C:\\test\\";            //"Test" is the folder to copy to
     
    system("copy input.c_str() output.c_str()")

    http://cboard.cprogramming.com/cplusplus-programming/109047-help-copy-files-cplusplus.html

    an0nym, 10 Сентября 2012

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

    +18

    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
    char* GetConnectionName(){return "";}
    //---
    char*  NetworkMgr::getErrorString(int id)
    {
        if(this->idValid(id))
    {
    return errors[id];
    }
    else
    {
    return "!!!unknown error!!!";
    }
    }

    Из тела одного большого класса, я конечно понимаю что строки хранятся не в стеке, но всеравно.

    Psionic, 10 Сентября 2012

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

    +45

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    Matrix::~Matrix()
    {    
    	data = NULL;
    	delete [] data;
    };

    no comments

    coll3ctor, 07 Сентября 2012

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

    +82

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    bool isOperator( char c ) {
    	return c == '+'
    		|| c == '-'
    		|| c == '*'
    		|| c == '/'
    		|| c == '('
    		|| c == ')';
    }

    Fai, 05 Сентября 2012

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