- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
bool SomeFuncrion ()
{
...................................
if (dbAttrList.size())
return true;
else
return false;
scroll( 0 , 0 );
}
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+168
bool SomeFuncrion ()
{
...................................
if (dbAttrList.size())
return true;
else
return false;
scroll( 0 , 0 );
}
А вдруг?
+166
void СSomeClass::InternalRemovePath( QString qsPath, int pUIModule )
{
QProgressDialog * pDlg = (QProgressDialog *)pUIModule;
...................
}
.......................
void someFunction ()
{
..................
QProgressDialog * pProgress = NULL;
pProgress = new QProgressDialog( QObject::tr( "Deleting...") , QObject::tr( "Abort" ), 0, nTotal, NULL );
InternalRemovePath( qsPath , (int) pProgress );
..................
}
И по коду таких вещей (приведение указателей к int при передаче в функции) очень много. Пока собрал проект, задолбался.
Интересно, что автор курил? Хотя, нет - тут уже что-то потяжелее.
+165
#define DEFAULT_TIMEOUT 30000
................................................
class CSettings //: public QSettings
{
................................................
static QVariant svalue( QString qs, QVariant defValue );
................................................
};
................................................
QString qs = QString("%1").arg( DEFAULT_TIMEOUT );
m_nTimeout = CSettings::svalue("connection/Timeout", qs.toAscii().data()).toString().toInt();
+160
#include <iostream>
#include <string>
using namespace std;
int main()
{
const int hz_limit = 20000;
string str;
string str_mass[] = {"a", "b", "ais", "h", "ces", "c", "his", "cis", "des",
"d", "dis", "es", "e", "fes", "f", "eis", "fis", "ges", "g", "gis", "as"};
begin:
while (cin>>str)
{
for (size_t ix = 0; ix != str.size(); ++ix)
{
str[ix] = tolower(str[ix]);
}
size_t f = 0;
for (size_t ix = 0; ix != 21; ++ix)
{
if(str == str_mass[ix])
{
f = ix;
}
}
if (str != str_mass[f])
{
goto begin;
}
double mass[] = {27.500, 29.135, 29.135, 30.868, 30.868, 32.703, 32.703, 34.648, 34.648,
36.708, 38.891, 38.891, 41.203, 41.203, 43.654, 43.654, 46.249, 46.249, 48.999, 51.913, 51.913};
for (; mass[f] < hz_limit; mass[f] *= 2)
{
cout<<mass[f]<<" Hz"<<endl;
}
}
return 0;
}
Моя первая прога. Выводит частоты на которых находится введенная нота...
+159
bool DoYouWannaRealyDoThisFunctionYesNo(T*(f)(T...), bool answer)
{
return answer;
}
Microsoft style
+159
bool Document::_Parse_Auto (char sym)
{
bool error = 0;
switch (mInfo.AutoState)
{
case 0:
{
if (is_stag (sym))
mInfo.AutoState = 1;
else
mInfo.AutoState = 14;
break;
}
case 1:
{
if (is_name (sym))
mInfo.AutoState = 24;
else if (is_delim (sym))
mInfo.AutoState = 2;
else if (is_prcom (sym))
mInfo.AutoState = 11;
else if (is_info (sym))
mInfo.AutoState = 25;
else if (is_ekey (sym))
mInfo.AutoState = 21;
else
error = true;
break;
}
<100500 строк case'ов>
case 26:
{
if (is_etag (sym))
mInfo.AutoState = 0;
else
error = true;
break;
}
}
return error;
}
void Document::_Parse_React (char sym)
{
switch (mInfo.AutoState)
{
case 0:
{
switch (mInfo.NodeType)
{
case ParseInfo::preproc:
{
delete mInfo.CurrentNode;
mInfo.CurrentNode = mInfo.LastTextNode;
break;
}
case ParseInfo::info:
{
delete mInfo.CurrentNode;
mInfo.CurrentNode = mInfo.LastTextNode;
break;
}
case ParseInfo::close:
{
if (mInfo.name == mInfo.CurrentNode->name)
mInfo.CurrentNode = mInfo.CurrentNode->parent;
else
{ mInfo.Error = 51; return; }
mInfo.name.clear ();
break;
}
}
break;
}
<ещё 100500 строк case'ов>
case 25:
{
mInfo.NodeType = ParseInfo::info;
mInfo.LastTextNode = mInfo.CurrentNode;
mInfo.CurrentNode = new Node;
break;
}
}
switch (mInfo.LastAutoState)
{
<и ещё 100500 строк case'ов>
Это я в 10 классе писал XML парсер, работающий на конечном автомате, в котором было 27 состояний.
+163
const QColor * c = & QColor.red;
const QColor * c = & QColor.rgb(12,12,12);
const QColor * c = & int QColor::red () const;
const int * c = & int QColor::red () const;
Взято отсюда: http://www.prog.org.ru/topic_16855_0.html
Особенно радует фраза: "Пробовал так <....> И другими способами, на которые вылетало множество ошибок".
+170
void Draw_Pixel_Memset(UINT color, //color = _RGB32BIT(a,r,g,b) ((b) + ((g) << 8) + ((r) << 16) + ((a) << 24))
UINT *buffer){ //buffer = (UINT*) ddsd.lpSurface
memset(buffer, color,8);
}
Рисование пикселя с помощью meset()
Подскажите, пожалуйста, почему при использование этой функции в 32 битном режиме точка получается какового то серого цвета.
С другой стороны если использовать 8 битный режим то пиксель будет нужного цвета.
Источник: http://www.gamedev.ru/code/forum/?id=145274
+168
#include <iostream>
using namespace std;
void main()
{
char U='#';
int K;
_asm
{
mov eax, 0
mov al, U
mov K,eax
}
cout<<K<<endl;
}
"Получение десятичного представления числа". C wasm.ru
+167
PopupWindow* GameLocations::getCurrentPopup()
{
if(m_curPopup != nullptr && m_curPopup->needsClose())
{
m_curPopup->onClose();
m_curPopup = nullptr;
m_walker->BeginWalk(m_graph->getClosestNode(m_currentLocationId));
}
return m_curPopup;
}