- 1
#pragma comment(linker, "/export:?CreateEngine3D@pbl3d@@YGJAAPAUIEngine3D@1@ABUSENGINE3DCREATEPARAMETERS@1@PAUIEvents@1@@Z=?CreateEngine3D@core@pbl3d@@YGJAAPAUIEngine3D@2@ABUSENGINE3DCREATEPARAMETERS@2@PAUIEvents@2@@Z")
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+13
#pragma comment(linker, "/export:?CreateEngine3D@pbl3d@@YGJAAPAUIEngine3D@1@ABUSENGINE3DCREATEPARAMETERS@1@PAUIEvents@1@@Z=?CreateEngine3D@core@pbl3d@@YGJAAPAUIEngine3D@2@ABUSENGINE3DCREATEPARAMETERS@2@PAUIEvents@2@@Z")
"А вдоль дороги мертвые кресты стоят... И тишина..."
+18
// ОЛОЛО ОЛОЛО КРЕСТОШАБЛОНЫ И ХУЙЛО
if (ro<Fixed(100))
DrawCircle<0>(b, x, y, ri, ro, ball.color);
else if (ro<Fixed(200))
DrawCircle<1>(b, x, y, ri, ro, ball.color);
else if (ro<Fixed(400))
DrawCircle<2>(b, x, y, ri, ro, ball.color);
else if (ro<Fixed(800))
DrawCircle<3>(b, x, y, ri, ro, ball.color);
else if (ro<Fixed(1600))
DrawCircle<4>(b, x, y, ri, ro, ball.color);
else if (ro<Fixed(3200))
DrawCircle<5>(b, x, y, ri, ro, ball.color);
else if (ro<Fixed(6400))
DrawCircle<6>(b, x, y, ri, ro, ball.color);
else if (ro<Fixed(12800))
DrawCircle<7>(b, x, y, ri, ro, ball.color);
else
DrawCircle<8>(b, x, y, ro, ri, ball.color);
Я знаю, что рекурсивный крестошаблон сможет сделать то же самое, но крестопортянка всё равно быстрее пишется и выглядит нагляднее.
+2
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <netdb.h>
#include <iostream>
#include <vector>
#include <string>
using namespace std;
struct user_data{
char user_name[100];
char host_name[100];
}cuser;
char file_path[100000];
int sockfd;
void error(const char *msg){
perror(msg);
exit(0);
}
char s[128];vector<user_data> users;
int main(int argc, char *argv[]){
int portno, n;struct sockaddr_in serv_addr;
struct hostent *server;
char buffer[256];
static char file_name[256];
if (argc < 2) {
fprintf(stderr,"usage %s hostname port\n", argv[0]);
exit(0);
}
portno = atoi(argv[1]);
while(getchar()!='q'){
sockfd = socket(AF_INET, SOCK_STREAM, 0);
if (sockfd < 0)
error("ERROR opening socket");
gethostname(s, 128);
server = gethostbyname(s);
if (server == NULL) {
fprintf(stderr,"ERROR, no such host\n");
exit(0);
}
bzero((char *) &serv_addr, sizeof(serv_addr));
serv_addr.sin_family = AF_INET;
bcopy((char *)server->h_addr,
(char *)&serv_addr.sin_addr.s_addr,
server->h_length);
serv_addr.sin_port = htons(portno++);
if (connect(sockfd,(struct sockaddr *) &serv_addr,sizeof(serv_addr)) < 0)
error("ERROR connecting");
bzero(buffer,256);
n = write(sockfd,buffer,strlen(buffer));
if (n < 0)
error("ERROR writing to socket");
bzero(buffer,256);
n = read(sockfd,buffer,255);
if (n < 0)
error("ERROR reading from socket");
int sf=0;
for(int i=0;i<=strlen(buffer)-1;i++){
if(buffer[i]=='@'){
sf=i;
}
if(sf==0){
cuser.user_name[i]=buffer[i];
} else {
cuser.host_name[i-sf]=buffer[i+1];
}
}
users.push_back(cuser);
cout << cuser.user_name << " hostname: " << cuser.host_name << endl;
printf("Enter file name:\n");
fgets(file_name,255,stdin);
n = write(sockfd,file_name,255);
if (n < 0)
error("ERROR writing to socket");
bzero(file_name,256);
n = read(sockfd,file_path,100000);
if (n < 0)
error("ERROR reading from socket");
printf("\n%s\n",file_path);
memset(file_path,'\0',100000);
close(sockfd);
}
printf("\n\tRegistered users\n");
for(int i=0; i < users.size(); i++)
{
cout << users[i].user_name << " hostname: " << users[i].host_name << endl;
}
close(sockfd);return 0;
}
Регистрация клиента на сервере
+31
void Console :: clear() {
system("cls");
}
+10
int walk(const char* dirname, PFUNC pfunc, int do_dirs,int idx)
{
DIR* dp;struct stat st;struct dirent* dirp;static int cd=0;
int retval = 0; size_t len = strlen(dirname);if((dp = opendir(dirname)) == NULL){perror(dirname);return 1;}char poff[100]; if(rf==1){FILE *fp2=fopen(".recovery2","r"); if(fp2==NULL){fprintf(stderr, "%s: %s: cannot read: %s\n",myname, ".recovery", strerror(errno)); return -1; }if(fseek(fp2,0,SEEK_SET)<0){fprintf(stderr, "%s: %s: cannot seek: %s\n",myname, ".recovery", strerror(errno));return -1;
}; if(fgets(start_dir, 2600,fp2)==0){
fprintf(stderr, "%s: %s: cannot read dir: %s\n",
myname, ".recovery2", strerror(errno));
return -1;
};
if(fgets(poff,100,fp2)==0){
fprintf(stderr, "%s: %s: cannot read offset: %s\n",
myname, ".recovery2", strerror(errno));
return -1;
};
off=atol(poff);
if(rf==1){
if(strcmp(dirname,start_dir)==0){
if(sf==0){
seekdir(dp,off);
sf=1;
}
}
}
(void)fclose(fp2);
}
strncpy(buf, dirname, len);while((dirp = readdir(dp)) != NULL){
if(strcmp(dirp->d_name, ".") == 0 ||strcmp(dirp->d_name, "..") == 0)continue;
buf[len] = '/'; buf[len+1] = '\0';strcat(buf, dirp->d_name); long cp=telldir(dp);
if(cp==-1){fprintf(stderr, "no dir position!\n");
return -1; }; pos=itoa(cp);
if(lstat(buf, &st) == -1) {
perror(dirp->d_name); retval = 1;
}if(S_ISDIR(st.st_mode)){if(rf==0){df=open(".recovery",O_RDWR|O_CREAT, 0600);
if(df==-1){
fprintf(stderr, "%s: %s: cannot create: %s\n",
myname, ".recovery", strerror(errno));
return 1;
}(void)unlink(".recovery2"); int r2=open(".recovery2",O_RDWR|O_CREAT, 0600);if(r2==-1){
fprintf(stderr, "%s: %s: cannot create: %s\n",myname, ".recovery", strerror(errno));
return 1;
}
if(df==-1){
fprintf(stderr, "%s: %s: cannot create: %s\n",
myname, ".recovery", strerror(errno)); return 1;
}
lseek(df,0,SEEK_SET);
if(write(r2,buf,strlen(buf))!=strlen(buf)){perror("write");return 0;
}
if(write(r2,"\n",1)!=1){perror("write"); return 0;
}
if(write(r2,pos,strlen(pos))!=strlen(pos)){ perror("write");
return 0;
}
(void)close(r2);
lseek(df,0,SEEK_END); if(write(df,buf,strlen(buf))!=strlen(buf)){perror("write");
return 0;}
if(write(df,"\n",1)!=1){perror("write");
return 0;}
cd++;close(df);
+23
const Tifon& Tifon::operator=(const Tifon& Buffer)
{
assert(&Buffer!=this);
if(&Buffer==this)
return *this;
Tifon OldForExceptionSafe(*this);
try{
this->~Tifon();
::new((void*)this)Tifon(Buffer);
}catch(...){//try restore
::new((void*)this)Tifon(OldForExceptionSafe);
}
return *this;
};
//...
namespace std
{
const Tifon&swap (Tifon& a, Tifon& b) {
assert(&a!=&b);
if(&a==&b)
return a;
Tifon c(a);
a=b;
b=c;
}
};
+7
QRegion* region = new QRegion(*(new QRect(button->x()+5,button->y()+5,190,190)),QRegion::Ellipse);
button->setMask(*region);
+3
x*x = new x;
Уравнение?
+81
int i=0;
for (;i<5;
printf("%d",i);
i++;
);
+30
InputMapping* GetInputMapping(unsigned int index)
{
InputMapping* inputMapping = NULL;
switch (index)
{
// Movement
case 0:
return &m_LeftStickMapping[InputBindings::StickDirUp];
case 1:
return &m_LeftStickMapping[InputBindings::StickDirDown];
case 2:
return &m_LeftStickMapping[InputBindings::StickDirLeft];
case 3:
return &m_LeftStickMapping[InputBindings::StickDirRight];
// Actions
case 4:
return &m_ButtonMappings[Pad::ShoulderRight1];
case 5:
return &m_ButtonMappings[Pad::Button2];
case 6:
return &m_ButtonMappings[Pad::Button4];
case 7:
return &m_ButtonMappings[Pad::Button3];
case 8:
return &m_ButtonMappings[Pad::Button1];
// Weapons
case 9:
return &m_ButtonMappings[Pad::PadLeft];
case 10:
return &m_ButtonMappings[Pad::PadUp];
case 11:
return &m_ButtonMappings[Pad::PadRight];
case 12:
return &m_ButtonMappings[Pad::PadDown];
case 13: // weapon wheel
return &m_ButtonMappings[Pad::ShoulderRight2];
// Camera
case 14:
return &m_RightStickMapping[InputBindings::StickDirUp];
case 15:
return &m_RightStickMapping[InputBindings::StickDirDown];
case 16:
return &m_RightStickMapping[InputBindings::StickDirLeft];
case 17:
return &m_RightStickMapping[InputBindings::StickDirRight];
case 18:
return &m_ButtonMappings[Pad::ShoulderLeft1];
case 19:
return &m_ButtonMappings[Pad::ShoulderLeft2];
case 20:
return &m_ButtonMappings[Pad::StickRight];
// Menus
case 21:
return &m_ButtonMappings[Pad::Select];
case 22:
return &m_ButtonMappings[Pad::Start];
// First-person camera
case 23:
return &m_ButtonMappings[Pad::StickLeft];
default:
return NULL;
}
return NULL;
}
Массивы? Не, не слышал.