- 1
#define RETURN_OR_THROW_EXCEPTION_IF_ERROR(Expression, Exception) if(!Expression) throw Exception; return Expression
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+1011
#define RETURN_OR_THROW_EXCEPTION_IF_ERROR(Expression, Exception) if(!Expression) throw Exception; return Expression
+991
unsigned long long int value=Bin<unsigned long long int>("1111111111111111111111111111111111111111111111111111111111111111");
+1009
#pragma once
#include <vector>
#include <algorithm>
#include <exception>
using namespace std;
template<typename nodeT>
class Tree
{
Tree* root;
Tree(Tree* _root, nodeT value)
: root(_root)
, Node(value)
{
}
vector<Tree> children;
public:
nodeT Node;
Tree(void) : root(nullptr) { }
Tree(const Tree& value)
: children(value.children)
, Node(value.Node)
, root(value.root)
{
}
virtual ~Tree(void) { }
const Tree& operator=(const Tree& value)
{
if(&value != this)
{
children = value.children;
for_each(children.begin(), children.end(), [this](Tree& tree)
{
tree.root = this;
});
Node = value.Node;
root = value.root;
}
return *this;
}
Tree& Root()
{
if(root == nullptr)
{
throw exception("already root");
}
return *root;
}
bool IsRoot() const
{
return root == nullptr;
}
Tree* Push(nodeT node)
{
children.push_back(Tree(this, node));
return &children.back();
}
Tree& operator[](typename vector<Tree>::size_type index)
{
return children[index];
}
vector<Tree*> Children()
{
vector<Tree*> result;
for(vector<Tree>::iterator i = children.begin(); i!=children.end(); i++)
{
result.push_back(&(*i));
}
return result;
}
typename vector<Tree>::iterator begin()
{
return children.begin();
}
typename vector<Tree>::iterator end()
{
return children.end();
}
};
Шаблон из http://govnokod.ru/6415.
+150
m_caster->HasAura(31866 || 31867 || 31868)
из одного эмулятора WoW Cataclysm
+1014
if (strlen(Uid.c_str()) > 0)
{
// ...
}
собственно, std::string Uid;
+1002
Нужно написать функцию, возводящую число в 10 степень.
Но почему, мой сотрудник обязательно напишет
double func (double a) {
return a * a * a * a * a * a * a * a * a * a;
}
??????
А когда понадобится 11 степень, он сделает так:
double func (double a, bool is11 = false) {
if (is11 == true)
return a * a * a * a * a * a * a * a * a * a * a;
return a * a * a * a * a * a * a * a * a * a;
}
А когда появится 12 степень, знаете что произойдет?
double func (double a, int stepen = 0) {
switch (stepen) {
case 0: return a * a * a * a * a * a * a * a * a * a; break;
case 1: return a * a * a * a * a * a * a * a * a * a * a; break;
case 2: return a * a * a * a * a * a * a * a * a * a * a; break;
}
return 0;
}
Источник: http://ibash.org.ru/quote.php?id=14755
+1005
#define STL_NO_INLINE __forceinline
А я думаю, почему в проекте, доставшемуся мне по наследству, exe'шник большой...
+161
QString str[5][5] = {"a", "b", "c", "d", "e",
"f", "g", "h", "i", "k",
"l", "m", "n", "o", "p",
"q", "r", "s", "t", "u",
"v", "w", "x", "y", "z"};
QString enc, text = ui->lineEdit->text();
int l = text.length();
QString tmp[1][8] = {"s", "o", "m", "e", "t", "e", "x", "t"};
for (int i = 0; i < 1; i++)
{
for (int j = 0; j < 9; j++)
{
for (int ix = 0; ix < 6; ix++)
{
for (int jx = 0; jx < 6; jx++)
{
if(tmp[i][j] == str[ix][jx])
enc = str[ix][jx + 1];
ui->lineEdit_2->setText(enc);
}
}
}
}
}
Такой-то квадрат Полибия!
+147
QT project:
t=x1; x1=x2; x2=t;
t=y1; x1=y2; y2=t;
И еще 90 говнопятнышек!
Налетай: http://www.viva64.com/ru/a/0077/
+146
#include<stdio.h>
#include<conio.h>
#include<math.h>
#include<stdlib.h>
void main(){
int Kliuci,X,Y,a,b,interval=10;
float T,sum=0;
m3:
clrscr();
printf("\n\r *****************\n\r");
printf(" 1|FOR\n\r");
printf(" 2|WHILE\n\r");
printf(" 0|EXIT\n\r");
printf(" ****************\n\r");
printf("Vvedite Kliuci:");
scanf("%d",&Kliuci);
switch(Kliuci)
{case 1 :
{//for
printf("Vvedite znacenia:a,b\n");
scanf("%d%d",&a,&b);
printf("Vvedite interval min 10 X=n<Y+Y:\n");
scanf("%d%d",&X,&Y);
printf("\n\r ********RESULT*******\r");
printf("\n\r --Interval-----Rezulitat\n\r");
for(int k=X*X;k<Y+1;k++)
{
T=pow(b,2)+a/2+(pow(a,4)/4)-(pow(b,6)/6)+k;
printf(" |\t %d",k);
printf("-");
printf("\t %f \n\r",T);
interval++;
sum+=T; }
printf("\n\r *********************\n\r");
printf("Vesi interval:%d\n\r",interval);
printf("Vesi rezulitat: %f",sum);
getch();}
break;
case 2:
{//while
printf("Vvedite znacenia:a,b\n");
scanf("%d%d",&a,&b);
printf("Vvedite interval min 10 X=n<Y+Y:\n");
scanf("%d%d",&X,&Y);
printf("\n\r ********RESULT********\r");
printf("\n\r --Interval-----Rezulitat\n\r");
int k=X*X;
while(k<Y+1)
T=pow(b,2)+a/2+(pow(a,4)/4)-(pow(b,6)/6)+k;
k++;
printf(" |\t %d",k);
printf("-");
printf("\t %f \n\r",T);
interval++;
sum+=T; }
printf("\n\r **********************\n\r");
printf("Vesi interval:%d\n\r",interval);
printf("Vesi rezulitat: %f",sum);
getch();
break;
case 0:
exit(0); }
break;
}
goto m3;}
http://hashcode.ru/questions/45871/где-ошибки-не-работает-компильтор
>goto
>void main
>...