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

    +9

    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
    class t_item{
    public:
    #define DEF_PRO_STRUCT_INFO(NAME,PARENT,OWNER)NAME(t_item)
    #define DEF_PRO_VARIABLE(ADDBEG,ADDVAR,ADDEND)\
    ADDBEG()\
    ADDVAR(0,string,name,DEF,$,$)\
    ADDVAR(1,int,next,SET,0,$)\
    ADDEND()
    //=====+>>>>>t_item
    #include "QapGenStruct.inl"
    //<<<<<+=====t_item
    public:
    };

    LispGovno, 12 Апреля 2014

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

    +14

    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
    string modify( const string & str )
    {
    	if( str.size() == 0 ) return "00";
    	if( str.size() == 1 ) return "0" + str;
    	return string( str.end() - 2, str.end() );
    }
    
    string modify4( const string & str )
    {
    	if( str.size() == 0 ) return "0000";
    	if( str.size() == 1 ) return "000" + str;
    	if( str.size() == 2 ) return "00" + str;
    	if( str.size() == 3 ) return "0" + str;
    	return string( str.end() - 4, str.end() );
    }
    
    string TimeISOFormat( time_t cur )
    {
    	char buf[32];
    	struct tm * timeinfo;
    	timeinfo = localtime ( &cur );
    	strftime(buf, 32, "%y", timeinfo);
    	string year(buf);
    	strftime(buf, 32, "%m", timeinfo);
    	string month(buf);
    	strftime(buf, 32, "%d", timeinfo);
    	string day(buf);
    	strftime(buf, 32, "%H", timeinfo);
    	string hour(buf);
    	strftime(buf, 32, "%M", timeinfo);
    	string minute(buf);
    	strftime(buf, 32, "%S", timeinfo);
    	string second(buf);
    	return modify4( year ) + "-" + modify( month ) + "-" + modify( day ) + "T" + modify( hour )+ ":" + modify( minute )+ ":" + modify( second );
    }
    
    string CurrentTimeISOFormat()
    {
    	time_t cur = CurrentTime();
    	char buf[32];
    	struct tm * timeinfo;
    	timeinfo = localtime ( &cur );
    	strftime(buf, 32, "%y", timeinfo);
    	string year(buf);
    	strftime(buf, 32, "%m", timeinfo);
    	string month(buf);
    	strftime(buf, 32, "%d", timeinfo);
    	string day(buf);
    	strftime(buf, 32, "%H", timeinfo);
    	string hour(buf);
    	strftime(buf, 32, "%M", timeinfo);
    	string minute(buf);
    	strftime(buf, 32, "%S", timeinfo);
    	string second(buf);
    	return modify4( year ) + "-" + modify( month ) + "-" + modify( day ) + "T" + modify( hour )+ ":" + modify( minute )+ ":" + modify( second );
    }
    
    time_t CurrentTime()
    {
    	time_t rawtime = 0;
    	time(&rawtime);
    	return rawtime;
    }

    brainiac, 11 Апреля 2014

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

    +9

    1. 1
    #define  FindElem( L )   _FindElem( [=] (VEC4 iter) -> bool  {  return (L);  } )

    На что только не пойдут люди, чтобы писать

    VEC4* pv = vecs.FindElem( iter.x==1.0f );

    laMer007, 07 Апреля 2014

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

    +57

    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
    #include <string>
    
    std::string SearchPushString(char StartVkPage[])
    {
    	char push[] = {'p','o', 's', 't'};
    	char http[] = {'h','t', 't', 'p'};
    	unsigned int* ipush = (unsigned int*)push;
    	unsigned long j = 0;
    	do
    	{
    		char* p = &StartVkPage[j];
    		unsigned int* nextFourSymbol = (unsigned int*)p;
    		if(nextFourSymbol[0]==ipush[0])
    		{
    			if(*p=='p')
    				ipush = (unsigned int*)http;
    			else
    			{
    				char* postString = new char[650];
    				memset(postString,0,650);
    				short int u = 0;
    				do
    				{
    					postString[u] = p[u];
    				}
    				while(p[++u]!='"'&&u!=650);
    				std::string url(postString);
    				delete [] postString;
    				return url;
    			}
    		}		
    	}
    	while(StartVkPage[j++]);
    	return std::string("error");
    }

    Я все никак не выучу регулярных выражений, ИЧСХ - обхожусь.

    Psionic, 06 Апреля 2014

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

    +22

    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
    /* macro is a way faster than inline */
    #define Compare(offsetx, offsety)                                              \
    do {                                                                           \
        int add;                                                                   \
        Point other = Get(g, x + offsetx, y + offsety);                            \
        if(offsety == 0) {                                                         \
            add = 2 * other.dx + 1;                                                \
        }                                                                          \
        else if(offsetx == 0) {                                                    \
            add = 2 * other.dy + 1;                                                \
        }                                                                          \
        else {                                                                     \
            add = 2 * (other.dy + other.dx + 1);                                   \
        }                                                                          \
        other.f += add;                                                            \
        if (other.f < p.f)                                                         \
        {                                                                          \
            p.f = other.f;                                                         \
            if(offsety == 0) {                                                     \
                p.dx = other.dx + 1;                                               \
                p.dy = other.dy;                                                   \
            }                                                                      \
            else if(offsetx == 0) {                                                \
                p.dy = other.dy + 1;                                               \
                p.dx = other.dx;                                                   \
            }                                                                      \
            else {                                                                 \
                p.dy = other.dy + 1;                                               \
                p.dx = other.dx + 1;                                               \
            }                                                                      \
        }                                                                          \
    } while(0)

    Нужно делать макросы ЕЩЕ больше!
    http://habrahabr.ru/post/215905/

    gost, 02 Апреля 2014

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

    +61

    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 <iostream>
    #include <iomanip>
    
    using std::boolalpha;
    using std::cout;
    using std::endl;
    
    template <class N>
    bool getbit(N var, int bit)
    {
        size_t bsz = sizeof(N)*8;
        return ((bsz>=bit)?((var>>bit)%2):(0));
    }
    
    template <class N>
    bool bitCompare(N a, N b)
    {
        size_t bsz = sizeof(N)*8;
    
    	for (size_t i = 0; i < bsz; i++)
    	{
            bool gba = getbit(a, i);
    		bool gbb = getbit(b, i);
    		if (gba != gbb)
    		{
    			return false;
    		}
    	}
    
    	return true;
    }
    
    int main(int argc, char* argv[])
    {
    	cout << "100500 == 100500:" << boolalpha << bitCompare(100500, 100500) << endl;
    	cout << "100500 == 9000: " << bitCompare(100500, 9000) << endl;
    	cout << "'H' == 'H': " << bitCompare('H', 'H') << endl;
    	cout << "'H' == 'K': " << bitCompare('H', 'K') << endl;
    
    	return 0;
    }

    Байтоебство проходили... Дамы и господа! Встречайте битоебство!

    gost, 29 Марта 2014

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

    +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
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    // Шифровка текста.
    
    char* encryption(char *Text){
       int i = 0;
    
       while(Text[i]){
          switch(Text[i]){
             default:
                Text[i] = '.';
                break;
             case 'a':
                Text[i] = ',';
                break;
             // ...
          }
          i++;
       }
       return Text;
    }

    Русские программисты обеспечивают безопасность данных ФСБ.

    Ignat776, 27 Марта 2014

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

    +77

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    // Решил узнать, что лучше C или C++.
    
       int C;
    
       if(C == C++)
          cout << "То же самое.";
       else 
          cout << "Разные.";

    C++ то же самое что и С.
    Как было сказано в одной книге компьютер очень глупый(Хоть он тут и не причём, компилятор подставил).

    Ignat776, 26 Марта 2014

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

    +11

    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
    float fNumber;
    //...
    //Куча бреда
    //...
       if(fNumber == +0)
          cout << "Неверно.;
       else if(fNumber == -0)
          cout << "Неверно.;
       else if(fNumber < +0 && fNumber > -0)
          cout << "У вас неправильная система счисления.";
       else{
          //...
       }

    Ignat776, 26 Марта 2014

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

    +8

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    int Speed = 1000; // 1000 тиков = 1 секунда
    int TimeBombs = 1020; // 1020 секунд = 17 минут
    
       while(TimeBombs){
          Sleep(Speed);
          if(Speed > 0)
             Speed--;
          TimeBombs--;
       }
    
       cout << "Бабах!";

    Террористам на заметку.

    Ignat776, 26 Марта 2014

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