- 1
- 2
- 3
- 4
- 5
function IPP (var i: integer): integer;
begin
Result := i;
Inc(i);
end;
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+76
function IPP (var i: integer): integer;
begin
Result := i;
Inc(i);
end;
−108
- (void) fixUIAfterRotation: (UIInterfaceOrientation) interfaceOrientation
{
[self.view setBackgroundColor:[UIColor colorWithPatternImage:[UIImage imageNamed:UIInterfaceOrientationIsPortrait(interfaceOrientation)? @"bg_new.png":@"bg_new_90.png"]]];
NSString *path = [[NSBundle mainBundle] bundlePath];
NSURL *baseURL = [NSURL fileURLWithPath:path];
NSString *htmlStr;
webError = NO;
orient = UIInterfaceOrientationIsPortrait(interfaceOrientation)? 1:2;
float width_ = [[UIScreen mainScreen] bounds].size.height;
viewNews.frame = isRotation? (UIInterfaceOrientationIsPortrait(interfaceOrientation)?
CGRectMake(0, 0, width_, 240):CGRectMake(0, 0, width_, width_ - 90)):(UIInterfaceOrientationIsPortrait(interfaceOrientation)? CGRectMake(0, 0, 320, width_ - 81):CGRectMake(0, 0, width_, 240));
isRotation = isRotation? NO:isRotation;
#if defined(PRO_PROJECT)
if (UIInterfaceOrientationIsPortrait(interfaceOrientation))
{
htmlStr = [NSString stringWithFormat:@"<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\"
\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\"><html xmlns=\"http://www.w3.org/1999/xhtml\">
<head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" /><title>Untitled Document</title>
<style>body {margin:0px; padding:0px; font:13px arial; background:none;}
a {text-decoration:underline; color:#fbcf04; font-weight:bold; !important;} a:hover {text-decoration:none;}
.title{background:#575757 left top repeat-x; font:bold 15px Arial; color:#FFF; padding:14px 30px 0px 0px; height:31px;
border-bottom:1px solid #000000; line-height:14px}.titleIm{background:#575757 left top repeat-x; padding:13px 8px 13px 13px; height:31px;
border-bottom:1px solid #000000;}.news_body {border-top:1px solid #414141; padding:10px 14px 14px 14px;
color:#FFF; line-height:19px; background:#3d3d3d;}.news_body p {padding-top:0px;}</style></head>
<body><table cellpadding=\"0\" cellspacing=\"0\" border=\"0\" width=\"320\" height=\"388\"><tr><td width=\"75\" valign=\"top\" class=\"titleIm\">
<img src=%@ height=\"70\" width=\"70\"></td><td valign=\"top\" class=\"title\">%@
<div style=\"font:11px Arial; color:#858585; line-height:18px;\">%@</div></td></tr><tr>
<td colspan=\"2\" valign=\"top\" class=\"news_body\">%@</td></tr></table></body></html>",
imageName, [newsDescription objectForKey:@"titleNews"],
[CORENewsTitleList getDataString:[newsDescription objectForKey:@"dateNews"]],
[newsDescription objectForKey:@"discriptionNews"]];
}
else
{
htmlStr = [NSString stringWithFormat:@"<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\"
\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\"><html xmlns=\"http://www.w3.org/1999/xhtml\">
<head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" /><title>Untitled Document</title>
<style>body {margin:0px; padding:0px; font:13px arial; background:none;}
a {text-decoration:underline; color:#fbcf04; font-weight:bold; !important;}a:hover {text-decoration:none;}
.title {background:#575757 left top repeat-x; font:bold 15px Arial; color:#FFF; padding:14px 30px 0px 0px; height:31px;
border-bottom:1px solid #000000; line-height:14px}.titleIm {background:#575757 left top repeat-x; padding:13px 8px 13px 13px; height:31px;
border-bottom:1px solid #000000;}.news_body {border-top:1px solid #414141; padding:10px 14px 14px 14px;
color:#FFF; line-height:19px; background:#3d3d3d;}.news_body p {padding-top:0px;}</style></head>
<body><table cellpadding=\"0\" cellspacing=\"0\" border=\"0\" width=\"%f\" height=\"240\"><tr><td width=\"75\" valign=\"top\" class=\"titleIm\">
<img src=%@ height=\"70\" width=\"70\"></td><td valign=\"top\" class=\"title\">%@
<div style=\"font:11px Arial; color:#858585; line-height:18px;\">%@</div></td></tr><tr>
<td colspan=\"2\" valign=\"top\" class=\"news_body\">%@</td></tr></table></body></html>",
width_, imageName, [newsDescription objectForKey:@"titleNews"],
[CORENewsTitleList getDataString:[newsDescription objectForKey:@"dateNews"]],
[newsDescription objectForKey:@"discriptionNews"]];
}
#else
if (UIInterfaceOrientationIsPortrait(interfaceOrientation))
{
// тот же упоротый код, что и выше, за исключением цветов для бэкграунда и надписей.
}
else
{
// тот же упоротый код, что и выше, за исключением цветов для бэкграунда и надписей.
}
#endif
[viewNews loadHTMLString:htmlStr baseURL:baseURL];
}
Поворачиваем вебвью во вью-контроллере, который может использоваться в 2 проектах, имеющих различные темы (отличается бэкграунд и цвет надписей).
+110
int strnlen(const char *s, int size)
{
int i;
for(i=0; i<size; i++) if(!*s) break;
return i;
}
+135
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define MAXSIZE 512
typedef struct word
{
char wordBody[MAXSIZE];
int count;
struct word* next;
} Word;
Word* alloc(char* incomeWord)
{
Word* ret;
ret = (Word*)malloc(sizeof(Word));
ret->count=1;
ret->next=NULL;
strcpy(ret->wordBody, incomeWord);
}
void insert(Word **n, char* incomeWord)
{
Word** p_p_n;
int h=0;
if(*n==NULL)
{
*n = alloc(incomeWord);
return;
}
for(p_p_n = n; *p_p_n!=NULL; p_p_n = &(*p_p_n)->next)
{
if((strcmp(incomeWord,&(*p_p_n)->wordBody))==0)
{
(*p_p_n)->count++;
return;
}
}
for(p_p_n = n; *p_p_n!=NULL; p_p_n = &(*p_p_n)->next)
{
Word* ins = alloc(incomeWord);
Word* temp = *p_p_n;
Word** tt;
int is=0;
tt=p_p_n;
ins->next=temp;
*p_p_n = ins;
break;
}
}
void print(Word* n)
{
while(n!=NULL) {
if(n->count > 1)
{
printf("%s %d\n", n->wordBody, n->count);
}
n=n->next;
}
}
int main(void)
{
char buf[MAXSIZE]={'\0'};
FILE *fr;
Word* sez=NULL;
fr=fopen("Text1.txt", "r");
while(!feof(fr))
{
fscanf(fr,"%s",buf);
insert(&sez,buf);
}
print(sez);
printf("\n%d\n", sizeof(sez));
fclose(fr);
return 0;
}
Считаем сколЬко раз каждое слово встречается в текстовом файле. Программа выполняется 6.5 минут с файлом размером 850 килобайт.
+79
//Unit1.h
const float RADIAN=0.01744444444;
TForm1 *Form1;
Graphics::TBitmap*ZadniyBuffer;
float ShipPosX,ShipPosY;
float ShipAngle;
float ShipSpeed;
bool LEFT,RIGHT,UP;
TList*Bullets;
TList*Asteroids;
class Bullet
{
public:
float x,y,dx,dy;
void CreateBullet()
{
x=ShipPosX;y=ShipPosY;
dx=10*cos(RADIAN*ShipAngle);
dy=10*sin(RADIAN*ShipAngle);
}
void Draw()
{
ZadniyBuffer->Canvas->Pen->Color=clRed;
ZadniyBuffer->Canvas->MoveTo(x,y);
ZadniyBuffer->Canvas->LineTo(x+dx,y+dy);
}
};
class CRock
{
public:
float x,y;
int Figure[50];
float Angle;
float Spin;
float XSpeed,YSpeed;
int Tip;
void CreateAsteroid(int t)
{
Tip=t;
XSpeed=random(4)+(random(9)/10.0)-2;
YSpeed=random(4)+(random(9)/10.0)-2;
Spin=random(10)-5;
for(int i=0;i<20;i++)
{
if(Tip==1)Figure[i]=random(10)+25;
if(Tip==2)Figure[i]=random(10)+10;
if(Tip==3)Figure[i]=random(5)+5;
}
}
void Move()
{
x+=XSpeed;y+=YSpeed;
Angle+=Spin;
if(x>440)x=-40;if(x<-40)x=440;
if(y>440)y=-40;if(y<-40)y=440;
}
void Draw()
{
ZadniyBuffer->Canvas->Pen->Color=clRed;
float tAng=0;
int tx=cos(RADIAN*(Angle+tAng))*Figure[0]+x;
int ty=sin(RADIAN*(Angle+tAng))*Figure[0]+y;
ZadniyBuffer->Canvas->MoveTo(tx,ty);
for(int i=0;i<20;i++,tAng+=19)
{
int tx=cos(RADIAN*(Angle+tAng))*Figure[i]+x;
int ty=sin(RADIAN*(Angle+tAng))*Figure[i]+y;
ZadniyBuffer->Canvas->LineTo(tx,ty);
}
}
};
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
randomize();
ZadniyBuffer=new Graphics::TBitmap();
ZadniyBuffer->Width =400;
ZadniyBuffer->Height=400;
ZadniyBuffer->Canvas->Pen->Color=clWhite;
Bullets =new TList();
Asteroids=new TList();
LEFT=false;RIGHT=false;
ShipPosX=200;ShipPosY=200;
ShipAngle=0;
ShipSpeed=0;
for(int i=0;i<4;i++)
{
CRock*a=new CRock();
a->x=random(400);
a->y=40;
a->CreateAsteroid(1);
Asteroids->Add((void*)a);
}
}
//---------------------------------------------------------------------------
void TForm1::CLS()
{
ZadniyBuffer->Canvas->Brush->Color=clBlack;
ZadniyBuffer->Canvas->FillRect(Rect(0,0,400,400));
Привет. Вот, украл, вернее, скачал с розришения автора код для курсача. На учебу билдера тупо времени нет, ибо есть много хвостов. Можете ли вы мне обьяснить весь код? Буду благодарен.
+75
echo( TRUE ? "1" : TRUE ? "2":"3");
//2
http://ideone.com/UBg3T2
В ответ на это:
http://govnokod.ru/12268#comment163978
+138
;;
;
;
;;;
void fuck()
{
puts("Fuck!");
getch();
}
void main (int argc, char ** argv) {
char ipstr[] = "192.168.1.140";
int ipint = IPStrToInt(ipstr);
atexit(fuck);
printf("%s == %ld\n",ipstr,ipint);
Init(1,main);
}
void Init(int govno) {
int * p = &govno;
void (*x) ()=(void *) *(p+1);
printf("%x", *p);
x((void *)0);
}
Оказывается, благодаря тому, что компилятору ссей пофиг на количество переданных в функцию аргументов, можно сделать неплохую реализацию while(true), который завершается тогда, когда соседним программам становится не насрать на переполнение стека...
+28
const std::string cyrillic = "аАбБвВгГдДеЕёЁжЖзЗиИйЙкКлЛмМнНоОпПрРсСтТуУфФхХцЦчЧшШщЩъЪыЫьЬэЭюЮяЯ";
std::string cyrillic_toupper(std::string s)
{
if(cyrillic.find(s) == std::string::npos)
throw std::runtime_error(std::string("cyrillic_toupper(): ") + "'" + s + "' is not cyrillic char");
return cyrillic.substr(cyrillic.find(s) + 2, 2);
}
−153
create table ISU.Н_ЛЮДИ
(
ИД NUMBER(9) not null,
ФАМИЛИЯ VARCHAR2(25) not null,
ИМЯ VARCHAR2(15) not null,
ОТЧЕСТВО VARCHAR2(20),
ПИН VARCHAR2(20),
ИНН VARCHAR2(20),
ДАТА_РОЖДЕНИЯ DATE not null,
ПОЛ CHAR(1) not null,
МЕСТО_РОЖДЕНИЯ VARCHAR2(200),
ИНОСТРАН VARCHAR2(3) not null,
ФИО VARCHAR2(80),
ДАТА_СМЕРТИ DATE default '09.09.9999' not null,
КТО_СОЗДАЛ VARCHAR2(40) default USER not null,
КОГДА_СОЗДАЛ DATE default SYSDATE not null,
КТО_ИЗМЕНИЛ VARCHAR2(40) not null,
КОГДА_ИЗМЕНИЛ DATE default SYSDATE not null
)
Мопед не мой.
PL/SQL, крупная организация.
Oracle, зачем ты разрешил кириллицу в именах полей?
+18
char* GetConnectionName(){return "";}
//---
char* NetworkMgr::getErrorString(int id)
{
if(this->idValid(id))
{
return errors[id];
}
else
{
return "!!!unknown error!!!";
}
}
Из тела одного большого класса, я конечно понимаю что строки хранятся не в стеке, но всеравно.