- 1
- 2
- 3
SetPixel (GetPixel (GetPixel (GetPixel (GetPixel (GetPixel ((COLORREF) rand(), (int) rand(), (int) rand());
#define SetPixel(GetPixel(GetPixel(GetPixel(GetPixel(GetPixel((COLORREF)rand(),(int)rand(),(int)rand());
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+148
SetPixel (GetPixel (GetPixel (GetPixel (GetPixel (GetPixel ((COLORREF) rand(), (int) rand(), (int) rand());
#define SetPixel(GetPixel(GetPixel(GetPixel(GetPixel(GetPixel((COLORREF)rand(),(int)rand(),(int)rand());
GetPixel возвращает преведущее значение пикселя.
Так что этот код павильный, и ничего не делает.
А 3 строчка защищает от таких ошибок!
+141
try
{
fIn = fopen(cszFileName, "rb");
if (fIn == 0)
throw (std::string("Can not open file: ") + cszFileName);
if (!ParseFile(fIn, pLookup))
throw (std::string("Bad file format. File: ") + cszFileName);
throw std::string("");
}
catch (std::string& e)
{
if (fIn != 0)
{
fclose(fIn);
fIn = NULL;
}
if (e.length() != 0)
{
throw std::exception(e.c_str());
}
}
Исправленный говнокод
+148
try
{
fIn = fopen(cszFileName, "rb");
if (fIn == 0)
{
throw (std::string("Can not open file: ") + cszFileName);
if (!ParseFile(fIn, pLookup))
throw (std::string("Bad file format. File: ") + cszFileName);
throw std::string("");
}
}
catch (std::string& e)
{
if (fIn != 0)
{
fclose(fIn);
fIn = NULL;
}
if (e.length() != 0)
{
throw std::exception(e.c_str());
}
}
Просто говнокод
+143.3
#define KOEF_A 31415926
#define KOEF_B 27182818
#define INIT_VAL 3091976
unsigned long dVal;
unsigned char rnd()
{
unsigned long r = dVal*KOEF_A + KOEF_B;
int m = dVal % 8;
dVal = r >> m;
dVal++;
return (unsigned char)(dVal & 0xFF);
}
void Encode(void* data, int len)
{
if( len < 1 ) return;
for( int i = 0; i < len; i++ )
{
int xval = rnd();
((char*)data)[i] ^= xval;
}
}
используется для шифрования и дешифрования файла
+103
byte* pSomeArr = new byte[nArrLen];
auto_ptr<byte> bAutoPtr(pSomeArr); // auto delete on exit
Защита от утечек памяти! =)
+38.2
platformY = ballY
Непроходимая игра.
1 мячик. 2 Платформы слева и справа.
Это код перемещения платформы робота по y.
+97.4
int main()
{
...
return rand();
}
Иногда даже вылетают ошибки!
+92
if (a > 5)
...
else if (a < 5)
...
else if (i == 5)
...
else
printf ("Сегодня плохой день!");
Плохой день)))
+31.1
void intaIs1intbIs2intcisAplusBHWNDwndIsgetWnd...()
{
int a = 1;
int b = 2;
int c = a + b;
HWND wnd = getWnd();
...
}
Тут все ясно
+150
if (a) b = true; else b = false;
В реале видел. Тупил минут 5, пытаясь понять внутренний смысл этой конструкции