- 1
- 2
- 3
- 4
- 5
- 6
- 7
if(count($a)>0)
{
for($i=0; $i<count($a); $i++)
{
//код код код
}
}
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+32.7
if(count($a)>0)
{
for($i=0; $i<count($a); $i++)
{
//код код код
}
}
что-то подобное)
+19
<?php
function word_filter($str) {
$filtered = '';
for ($i = 0; $i <= strlen($str) - 1; $i++) {
$char = substr($str, $i, 1);
if (ctype_alpha($char)) {
$filtered .= $char;
}
}
return $filtered;
}
как делают дебилы: $i <= strlen($str) - 1;
кто знает, так - $j = strlen($str), $i < $j
+20.2
year = ORIGINYEAR; /* = 1980 */
while (days > 365)
{
if (IsLeapYear(year))
{
if (days > 366)
{
days -= 366;
year += 1;
}
}
else
{
days -= 365;
year += 1;
}
}
Код часов в M$ Zune 30GB.
+30
for i := 0 to high(vParagsChanges) do
begin
if vParNumIn < vParagsChanges[i].ParNo1 then
begin
inc(vParNumOut, vParagsChanges[i].ParNo1 - vParNumIn);
vParNumIn := vParagsChanges[i].ParNo1;
end;
if i < high(vParagsChanges) then
if (vParagsChanges[i].ParNo1+vParagsChanges[i].Range=vParagsChanges[i+1].ParNo1) and
((vParagsChanges[i].Kind=ckDelete) and (vParagsChanges[i+1].Kind=ckAdd)) then
{if vParagsChanges[i].Range = vParagsChanges[i+1].Range then}
begin
vUnitedPars := min(vParagsChanges[i].Range, vParagsChanges[i+1].Range);
if vParagsChanges[i+1].Range >= vUnitedPars then
vParagsChanges[i+1].Range := vParagsChanges[i+1].Range - vUnitedPars;
if vParagsChanges[i].Range >= vUnitedPars then
vParagsChanges[i].Range := vParagsChanges[i].Range - vUnitedPars;
for j := 0 to vUnitedPars-1 do
begin
FParsHL[vParNumIn+vInsertedCount1+j].Kind := pkReplaced;
vTagsInfoEx := GetTagsInfo(Editor1.Parag(vParNumIn+vInsertedCount1+j).Str);
FParsHL[vParNumIn+vInsertedCount1+j].ViewGroups := GetViewGroupsByChangeItems(vTagsInfoEx.TagKinds);
vTagsInfoEx := GetTagsInfo(Editor2.Parag(vParNumIn+vInsertedCount1+j).Str);
FParsHL[vParNumIn+vInsertedCount1+j].ViewGroups := FParsHL[vParNumIn+vInsertedCount1+j].ViewGroups + GetViewGroupsByChangeItems(vTagsInfoEx.TagKinds);
if vParagsChanges[i].InCard then
FParsHL[vParNumIn+vInsertedCount1+j].ViewGroups := FParsHL[vParNumIn+vInsertedCount1+j].ViewGroups + [vgCard]
else
FParsHL[vParNumIn+vInsertedCount1+j].ViewGroups := FParsHL[vParNumIn+vInsertedCount1+j].ViewGroups + [vgText];
end;
inc(vParNumIn, vUnitedPars);
inc(vParNumOut, vUnitedPars);
end;
case vParagsChanges[i].Kind of
ckAdd: begin
for j := 0 to vParagsChanges[i].Range-1 do
begin
vTmpParag := TRTFParag.Create(nil, False, False, raLeft{raRight});
FEditor1.InsPar(vParNumIn+vInsertedCount1+j, vTmpParag, false);
FParsHL[vParNumIn+vInsertedCount1+j].Kind := pkAdded;
vTagsInfoEx := GetTagsInfo(Editor2.Parag(vParNumOut+vInsertedCount2+j).Str);
if vParagsChanges[i].InCard then
FParsHL[vParNumIn+vInsertedCount1+j].ViewGroups := GetViewGroupsByChangeItems(vTagsInfoEx.TagKinds) + [vgCard]
else
FParsHL[vParNumIn+vInsertedCount1+j].ViewGroups := GetViewGroupsByChangeItems(vTagsInfoEx.TagKinds) + [vgText];
end;
inc(vInsertedCount1, vParagsChanges[i].Range);
inc(vParNumOut, vParagsChanges[i].Range);
end;
ckDelete: begin
for j := 0 to vParagsChanges[i].Range-1 do
begin
vTmpParag := TRTFParag.Create(nil, False, False, raLeft);
FEditor2.InsPar(vParNumOut+vInsertedCount2+j, vTmpParag, false);
FParsHL[vParNumOut+vInsertedCount2+j].Kind := pkDeleted;
vTagsInfoEx := GetTagsInfo(Editor1.Parag(vParNumIn+vInsertedCount1+j).Str);
if vParagsChanges[i].InCard then
FParsHL[vParNumOut+vInsertedCount2+j].ViewGroups := GetViewGroupsByChangeItems(vTagsInfoEx.TagKinds) + [vgCard]
else
FParsHL[vParNumOut+vInsertedCount2+j].ViewGroups := GetViewGroupsByChangeItems(vTagsInfoEx.TagKinds) + [vgText];
end;
inc(vInsertedCount2, vParagsChanges[i].Range);
inc(vParNumIn, vParagsChanges[i].Range);
end;
ckModify: begin
if (ciAlignment in vParagsChanges[i].ChangedItems) and (vParagsChanges[i].StrChanges = nil) then
FParsHL[vParNumIn+vInsertedCount1].Kind := pkAlignment
else
FParsHL[vParNumIn+vInsertedCount1].Kind := pkModified;
FParsHL[vParNumIn+vInsertedCount1].Changes := GetViewChanges(vParagsChanges[i].StrChanges);
FParsHL[vParNumIn+vInsertedCount1].ViewGroups := GetViewGroupsByChangeItems(vParagsChanges[i].ChangedItems);
if vParagsChanges[i].InCard then
if (ciText in vParagsChanges[i].ChangedItems) or (ciAlignment in vParagsChanges[i].ChangedItems) then
begin
FParsHL[vParNumIn+vInsertedCount1].ViewGroups := FParsHL[vParNumIn+vInsertedCount1].ViewGroups + [vgCard];
FParsHL[vParNumIn+vInsertedCount1].ViewGroups := FParsHL[vParNumIn+vInsertedCount1].ViewGroups - [vgText, vgAlignment];
for j := 0 to high(FParsHL[vParNumIn+vInsertedCount1].Changes) do
if FParsHL[vParNumIn+vInsertedCount1].Changes[j].ViewGroup = vgText then
FParsHL[vParNumIn+vInsertedCount1].Changes[j].ViewGroup := vgCard;
end;
inc(vParNumIn, 1);
inc(vParNumOut, 1);
end;
end;
end;
Такой г****код возник не за 1 день. Голову пришлось поломать основательно :))
Комментарии убраны, дабы не портить удовольствие от прочтения.
+15.3
#define begin {
#define end }
....
//==================================
// put a big character on the screen
// c is index into bitmap
void video_putchar(char x, char y, char c)
begin
v7 = x;
for (v6=0;v6<7;v6++)
begin
v1 = bitmap[c][v6];
v8 = y+v6;
...
end
end
паскалист пишет на си
+10.8
// собственно заполнение
for (i = pdir ? old_end_y : old_end_x; i != pdir ? (sel_end_y + gstep) : (sel_end_x + gstep); i++)
{
if (cells[pdir ? sel_x : i][pdir ? i : sel_y])
freemem(cells[pdir ? sel_x : i][pdir ? i : sel_y]);
if (is_arith)
{
cells[pdir ? sel_x : i][pdir ? i : sel_y] = ftoa(arith_first);
arith_first += arith_step;
}
else
{
if (cells[sel_x][sel_y])
{
cells[pdir ? sel_x : i][pdir ? i : sel_y] = (char*)allocmem(strlen(cells[sel_x][sel_y]) + 1);
strcpy(cells[pdir ? sel_x : i][pdir ? i : sel_y], cells[sel_x][sel_y]);
}
}
Индус помешался на тернарной операции.
+17.4
for (i = 0; i<sizeof(n)*4; i++)
{
if ((((n>>(2*i))&1==1)&&((n>>(2*i+1))&1==0)))
{
n|=(1<<(2*i));
n&=~(1<<(2*i+1));
}
else if ((((n>>(2*i))&1==0)&&((n>>(2*i+1))&1==1)))
{
n|=(1<<(2*i+1));
n&=~(1<<(2*i));
}
Нечто вроде циклического сдвига вправо на Си.
−282.3
query = "select coach_id, "
" concat(coach_surname,' ',coach_name,' ',coach_pname, ' (', (select name from price_coach_types where id_coach_type = coaches.coach_type), ')'), "
"ifnull((select price_single_child from price_coaches where coach_id = coaches.coach_id and price_start_date = " + actual_price+ "),0),"
"ifnull((select price_single_adult from price_coaches where coach_id = coaches.coach_id and price_start_date = " + actual_price+ "),0),"
"ifnull((select price_group_child from price_coaches where coach_id = coaches.coach_id and price_start_date = " + actual_price+ "),0),"
"ifnull((select price_group_adult from price_coaches where coach_id = coaches.coach_id and price_start_date = " + actual_price+ "),0)"
" from coaches order by binary coach_surname, coach_type";
Автор любитель копипастить свой код :)
+29
double StrToMoney(AnsiString str)
{
str = AnsiReplaceStr(str, "-", ".");
char *buffer = str.c_str();
double val;
sscanf(buffer,"%lf",&val);
return val;
}
Быдлокодер на борланд С++ хотел сконвертить в число деньги в формате рубли-копейки. И сделал это наименее эффективным образом.
−430.2
#начало индусокода
def desyatka(number):
return int(number/10.0)
def edenica(number):
return number-desyatka(number)*10
hours_string=[]
for a in range(0,30):
zzz=""
if edenica(a)<5:
zzz = " часа "
if edenica(a)==1:
zzz = " час "
if desyatka(a)==1:
zzz = " часов "
if edenica(a)==0:
zzz = " часов "
if zzz=="":
zzz=" часов "
hours_string.append(zzz)
minutes_string=[]
for a in range(0,60):
zzz=""
if edenica(a)<5:
zzz = " минуты "
if edenica(a)==1:
zzz = " минута "
if desyatka(a)==1:
zzz = " минут "
if edenica(a)==0:
zzz = " минут "
if zzz=="":
zzz=" минут "
minutes_string.append(zzz)
seconds_string=[]
for a in range(0,60):
zzz=""
if edenica(a)<5:
zzz = " секунды "
if edenica(a)==1:
zzz = " секунда "
if desyatka(a)==1:
zzz = " секунд "
if edenica(a)==0:
zzz = " секунд "
if zzz=="":
zzz=" секунд "
seconds_string.append(zzz)
#конец индусокода
Ф-ии, склоняющие по падежам и временам слова "часов", "минут", секунд