- 1
- 2
- 3
- 4
#define loopv(v) for(int i = 0; i<(v).length(); i++)
#define loopvj(v) for(int j = 0; j<(v).length(); j++)
#define loopvk(v) for(int k = 0; k<(v).length(); k++)
#define loopvrev(v) for(int i = (v).length()-1; i>=0; i--)
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+168
#define loopv(v) for(int i = 0; i<(v).length(); i++)
#define loopvj(v) for(int j = 0; j<(v).length(); j++)
#define loopvk(v) for(int k = 0; k<(v).length(); k++)
#define loopvrev(v) for(int i = (v).length()-1; i>=0; i--)
Может я чего недопонимаю?
Это из Cube 2: Sauerbraten
+149
matrix[0][0]=3;
matrix[0][1]=1;
matrix[0][2]=1;
matrix[0][3]=6;
matrix[1][0]=0;
matrix[1][1]=-2;
matrix[1][2]=1;
matrix[1][3]=-3;
matrix[2][0]=2;
matrix[2][1]=-1;
matrix[2][2]=4;
matrix[2][3]=-1;
cout<<"MATRIX:"<<endl;
for (i=0;i<4;i++) {
cout<<matrix[0][i]<<" ";
if (i==3) {
cout<<" "<<endl;
for (i=0;i<4;i++) {
cout<<matrix[1][i]<<" ";
if (i==3) {
cout<<" "<<endl;
for (i=0;i<4;i++) {
cout<<matrix[2][i]<<" ";};};};};};
Вывод двумерного массива :)
+164
srand(time(0));
for (i = 0; i < 10000; i++) {
sprintf(qtrc, "/tmp/%010d", rand());
if (!mkdir(qtrc, 0700))
goto okay;
}
logPanic("Cannot create $HOME\n");
okay:
Исходники KDM
+160
std::string ScriptInfo::GetDebugInfo() const
{
char sz[256];
sprintf(sz, "%s ('%s' script id: %u)", GetScriptCommandName(command).c_str(), GetScriptsTableNameByType(type).c_str(), id);
return std::string(sz);
}
Может, не совсем говнокод, но меня от подобного коробит.
+162
/*
Макрос генерирует внутренности функции-заглушки OpenGL.
*/
#define BWT_DECLARE_OPENGL_PROC_IMPL(PROC, PROC_TYPE, ...) \
static PROC_TYPE _##PROC = 0; \
\
if (_##PROC) \
return _##PROC(__VA_ARGS__); \
else \
{ \
_##PROC = TryToGetProcAddress<PROC_TYPE>(#PROC); return _##PROC(__VA_ARGS__); \
}
/*
Функция получает адрес функции, или возбуждает исключение, если адрес получить не удалось.
*/
template<typename proc_type>
proc_type TryToGetProcAddress(const char *proc_name) throw(error_type<VIDEO>)
{
proc_type address = reinterpret_cast<proc_type>(::SDL_GL_GetProcAddress(proc_name));
if (!address)
BWT_THROW_VIDEO_ERROR(UNDEFINED_ERROR, "OpenGL version does not supported");
return address;
}
GLAPI void APIENTRY glCullFace (GLenum mode)
{
BWT_DECLARE_OPENGL_PROC_IMPL(glCullFace, PFNGLCULLFACEPROC, mode);
}
...
+160
#include <iostream>
using namespace std;
int main(){
char b,a[1001];
int i, c=0;
cin >> b;
for(i=1; i<=1000; i++)
cin >> a[i];
for( i=1; i<=1000; i++)
if(a[i]=='b') c++;
cout <<c<<" "<<b<<" characters in ";
for(i=1; i<=1000; i++)
cout << a[i];
return 0;
} //помогите найти ошибку
Источник - http://tinyurl.com/26n9df5
+154
String boo = value[i]/*.ConvertTo<String>()*/;
std::string boovalue(boo.Value());
st.bind(1+i, boovalue.c_str());
+164
#define MERGE(X,Y) X##Y
typedef unsigned MERGE(ch,ar) byte;
+157
if ( условие ) ;
{
//что-либо сделать
};
//"счастливой отладки" v.2.0
отгреб в собственном-же коде)))))
+191
// I am not responsible of this code.
// They made me write it, against my will.
double penetration;
http://community.livejournal.com/programmers_fun/65300.html