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

    −30

    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
    84. 84
    85. 85
    86. 86
    87. 87
    88. 88
    89. 89
    90. 90
    91. 91
    #include <iostream>
    #include <conio.h>
    
    
    using namespace std;
    
    
    char* find(char* str)
    {
    	int i = 0, mlen=0;
    	char* minword = new char[100];
    	char* curword = new char[100];
    	while(str[i]==' ') i++;
    	mlen = i;
    	while((str[mlen]!=' ')&&(str[mlen])) mlen++;
    	mlen -= i;
    	strncpy(minword, str+i, mlen);
    	minword[mlen] = '\0';
    	i += mlen;
    	while(str[i])
    	{		
    		while(str[i]==' ') i++;
    		mlen = i;
    		while((str[mlen]!=' ')&&(str[mlen])) mlen++;
    		mlen -= i;
    		strncpy(curword, str+i, mlen);
    		curword[mlen] = '\0';
    		i += mlen;
    		
    		if(strcmp(minword, curword) > 0)
    		{
    			strcpy(minword, curword);
    		}
    	}
    	return minword;
    }
    
    void del(char*& str, char* str2)
    {
    	int i = 0, j =0, st=0;
    	char* nstr = new char[200];
    	
    	while(str[i])
    	{
    			j = 0;
    			while(str[i]==str2[j])
    			{
    				i++; j++;
    			}
    			if(j==strlen(str2))
    			{
    				strncpy(nstr, str+st, i-j);
    				nstr[i-j] = '\0';
    				st = i;
    				break;
    			}
    			i++;
    	}
    	strcat(nstr, str+st);
    	str = nstr;
    }
    
    
    void sort(char*& str)
    {
    	int len = strlen(str);
    	char* nstr = new char[200];
    	char* buf = new char[200];
    	buf = find(str);
    	strcpy(nstr, buf);
    	del(str, buf);
    	while(strlen(nstr) != len)
    	{
    		buf = find(str);
    		strcat(nstr, " ");
    		strcat(nstr, buf);
    		del(str, buf);
    	}
    	nstr[len] = '\0';
    	str = nstr;
    }
    
    
    
    void main()
    {
    	char* str = new char[200];
    	str = "my little pony";
    	sort(str);
    	cout<<str;
    }

    Из вузовского компьютера.

    dos_, 03 Июня 2012

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

    −52

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    /// Get the x-axis
    b2Vec2 GetXAxis() const
    {
    	return b2Vec2(c, s);
    }
    
    /// Get the u-axis
    b2Vec2 GetYAxis() const
    {
    	return b2Vec2(-s, c);
    }

    Box2D, говнокомментарий

    tymofey, 01 Июня 2012

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

    −43

    1. 1
    int eger;

    dos_, 30 Мая 2012

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

    −32

    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
    #pragma once
    
    #include <vector>
    #include <assert.h>
    
    class Obj
    {
    public:
    	virtual ~Obj(void) { }
    };
    
    
    class Sig
    {
    	typedef void (Obj::*slot_t)(void*);
    	mutable std::vector<std::pair<Obj*, Sig::slot_t>> m_connSlots;
    
    public:
    	void operator()(void* arg) const
    	{
    		std::vector< std::pair<Obj *, slot_t> >::const_iterator iter = m_connSlots.cbegin();
    		while(iter != m_connSlots.cend())
    		{
    			Obj * object = iter->first;
    			slot_t slot = iter->second;
    			(object->*slot)(arg);
    			iter++;
    		}
    	}
    
    	template<class obj_T> void connect(obj_T* object, void (obj_T::*slot)(void*)) const
    	{
    		assert(dynamic_cast<Obj*>(object)!=0);
    		m_connSlots.push_back(std::make_pair(reinterpret_cast<Obj*>(object),
    			reinterpret_cast<Sig::slot_t>(slot)));
    	}
    };

    QBicycle

    Xom94ok, 30 Мая 2012

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

    −32

    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
    //
    //	std::string wrapper
    //
    namespace priv {
    	class string {
    		std::string &m_s;
    
    		std::string &(std::string::*m_pAssign1)( const char *, std::string::size_type );
    		std::string &(std::string::*m_pAssign2)( const char * );
    
    	public:
    		string( std::string &str ): m_s(str),
    			m_pAssign1(&std::string::assign), m_pAssign2(&std::string::assign) {}
    
    		string &assign( const char *s, std::string::size_type n )
    		{
    			(m_s.*m_pAssign1)( s, n ); return *this;
    		}
    		string &assign( const char *s )
    		{
    			(m_s.*m_pAssign2)( s ); return *this;
    		}
    	};
    }

    сегодня ассимилирую старый хлам на работе (проекты VC6) в студию с нормальными свойствами проектов, конфигурациями, неабсолютными путями и т.д.
    наткнулся в одной из либ на вот это

    defecate-plusplus, 30 Мая 2012

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

    −37

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    int LoggingProvider::AddJournalPackingLogRecord(int eventId, const astring& userId, 
                                                  const std::vector<std::string>& journals, int errorId, int devCode,
                                                  int sysCode, const astring& errorArgs)
    {
        std::string strUserId(userId.c_str()), strErrorArgs(errorArgs);
    
        return AddJournalPackingLogRecord(eventId, userId, journals, errorId, devCode, sysCode, strErrorArgs);
    }

    Рекурсия!

    tob1az, 30 Мая 2012

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

    −40

    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
    /*
    	 * This GtkIMHtml has the maximum number of smileys allowed, so don't
    	 * add any more.  We do this for performance reasons, because smileys
    	 * are apparently pretty inefficient.  Hopefully we can remove this
    	 * restriction when we're using a better HTML widget.
    	 */
    	unescaped = purple_unescape_html(smiley);
    	numsmileys_thismsg = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(imhtml), "gtkimhtml_numsmileys_thismsg"));
    	if (numsmileys_thismsg >= 30) {
    		gtk_text_buffer_insert(imhtml->text_buffer, iter, unescaped, -1);
    		g_free(unescaped);
    		return;
    	}
    	numsmileys_total = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(imhtml), "gtkimhtml_numsmileys_total"));
    	if (numsmileys_total >= 300) {
    		gtk_text_buffer_insert(imhtml->text_buffer, iter, unescaped, -1);
    		g_free(unescaped);
    		return;
    	}

    Вот такой прикол от Pidgin. Больше 30 смайлов в сообщении и 300 в диалоге - низя. Захардкодили, ибо стыдно, что тормозит. А оно действительно тормозит.

    g0rky, 29 Мая 2012

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

    −30

    1. 1
    2. 2
    TempAnalogTable[ArrayData->GetNomerElement( j )].Data = 
                Chanel.TempPlace[in] + ( Chanel.TempPlace[in + 1] << 8 );

    Скажите, это нормально?

    cyrax, 29 Мая 2012

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

    +25

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    #ncld<strm.h>
    vd mn()
    {
    ct<<"Hll, wrld!";
    cn.gt();
    }

    Нхй пргрммрвн.

    dos_, 29 Мая 2012

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

    −28

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    template<typename T, int $1, int _2> struct Matrix
    {
        ...
        Vector<T, _2> vectors[$1];
    };

    HaskellGovno, 21 Мая 2012

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