- 1
- 2
- 3
- 4
if (strlen(Uid.c_str()) > 0)
{
// ...
}
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+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
>...
+1004
init1();
!isFailed1() && init2();
!isFailed1() && !isFailed2() && init3();
!isFailed1() && !isFailed2() && !isFailed3() && work();
!isFailed3() && cleunUp3();
!isFailed2() && cleunUp2();
!isFailed1() && cleunUp1();
И этот думает, что RAII не нужен.
+1000
int i = 0;
init1();
++i;
if (!isFailed1()) goto clean_up;
init2();
++i;
if (!isFailed2()) goto clean_up;
init3();
++i;
if (!isFailed3()) goto clean_up;
goto end:
clean_up:
switch(i) {
case 3:
cleunUp3();
case 2:
cleunUp2();
case 1:
cleunUp1();
}
end:
Он думает, что RAII не нужен.
+997
list<int> l;
//...
for(int i=0;i<l.size();++i)
{
auto it=l.begin();
advance(it, i);
int item=*it;
//...
+162
template <
typename PropertyOwner // Класс владельца
>
class properties {
public:
// Получить указатель на владельца по указателю на свойство
static PropertyOwner * owner( void * property ) {
int aai = (int)&(((PropertyOwner*)0)->__properties);
return (PropertyOwner *)((char*)property - aai);
}
};
/**
* Шаблон класса свойства
*/
template <
typename PropertyOwner, // Класс владельца
typename PropertyType, // Тип свойства
PropertyType (PropertyOwner::*getter)(), // Геттер
void (PropertyOwner::*setter)(PropertyType) > // Сеттер
class property {
public:
/**
* Чтение свойства - вызов геттера
*/
operator PropertyType() {
return (properties<PropertyOwner>::owner( this )->*getter)();
}
/**
* Запись в свойство - вызов сеттера
*/
void operator = ( const PropertyType & value ) {
(properties<PropertyOwner>::owner( this )->*setter)( value );
}
};
// Макросы для удобного определения свойств /////////
/**
* Начать объявления свойств в классе cls
*/
#define properties_start(cls) union { properties<cls> __properties;
/**
* Закончить объявление свойств в классе cls
*/
#define properties_end() };
/**
* Объявить свойство в классе cls типа type c геттером getter и сеттером setter
*/
#define property(cls,type,getter,setter) property<cls,type,&cls::getter,&cls::setter>
http://www.codenet.ru/progr/cpp/cpp-properties.php