首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C语言 >

接受批评,码风面目一新

2014-01-22 
接受批评,码风焕然一新贴出来,中文乱码了,还超过了9934个字符,所以删了部分。这次缩进了,不知如何?这次main

接受批评,码风焕然一新
贴出来,中文乱码了,还超过了9934个字符,所以删了部分。
这次缩进了,不知如何?
这次main函数短了,不知如何?
这次goto能少用少用了,不知如何?
这次加了点注释了,不知如何?

/*  get the score 
 *  date:2014.1.13
 *  by chen
 *  everything will be ok
 */
#include <stdio.h>
#include"conio.h"
#include<time.h>
#include"winsock2.h"
#include <string.h>
#include "md5.h"
#include "memory.h"
#pragma comment(lib, "ws2_32.lib")
char info[30000]="";
char info2[3700]="",xuefen[4],pmrs[10];
int rs,zg,zd,pm,sc,pc,zc,mc,zongc,for_act=0,to_act=0,bjg=0,jg=0;
char md5[35];
int isnum(char n)//is number
{
if(n=='0'||n=='1'||n=='2'||n=='3'||n=='4'||n=='5'||n=='6'||n=='7'||n=='8'||n=='9')
return 1;
return 0;
}
void gotoxy(int x,int y)//move cursor
{
int xx=0x0b;
HANDLE hOutput;
COORD loc;
loc.X=x;
loc.Y=y;
hOutput=GetStdHandle(STD_OUTPUT_HANDLE);
SetConsoleCursorPosition(hOutput,loc);
return;
}
void tit(char q[],int n,char *a,int p,char *b,int o,char *c,int ii)
{
char c2[587];
sprintf(c2,"title=%s%d  %s%d  %s%d  %s%d  ",q,n,a,p,b,o,c,ii);
system(c2);
}
void hz(int n)//print red  word
{
}
void lz(int n)//print green word
{
}
int pock(char *sendbuf,int flag) {

// Send and receive data.
int bytesSent,i;
int bytesRecv = strlen(sendbuf);
char recvbuf[1025]="";
bytesSent = send( m_socket, sendbuf, strlen(sendbuf), 0 );
bytesRecv = recv(m_socket, recvbuf,1024 , 0);
recvbuf[bytesRecv+1] = 0;
switch(flag)//1.get Account2.get score3.get order
{
case 1:
strcpy(info,recvbuf);
closesocket(m_socket);
return 0;
case 2:strcpy(info,recvbuf);
while(1) {
bytesRecv = recv(m_socket, recvbuf,1024 , 0);
if (bytesRecv <= 0) break;
recvbuf[bytesRecv+1] = 0;
strcat(info,recvbuf);
i=0;
while(recvbuf[i]!=0)
{
while(recvbuf[i]!='r')
if(recvbuf[i]==0)
goto nuno;
else
i++;
if(recvbuf[i+1]&&recvbuf[i+2]&&recvbuf[i+3]&&recvbuf[i+4])
if(recvbuf[i+1]=='e'&&recvbuf[i+2]=='s'&&recvbuf[i+3]=='e'&&recvbuf[i+4]=='t')
return 0;
else{}
else{}
i++;
}
nuno:;
}
closesocket(m_socket);
return 0;
case 3:strcpy(info2,recvbuf);
while(1) {
bytesRecv = recv(m_socket, recvbuf,1024 , 0);
if (bytesRecv <= 0) break;
recvbuf[bytesRecv+1] = 0;
strcat(info2,recvbuf);
i=0;
while(recvbuf[i]!=0)
{
while(recvbuf[i]!='/')
if(recvbuf[i]==0)
goto nuno1;
else
i++;
if(recvbuf[i+1]&&recvbuf[i+2]&&recvbuf[i+3]&&recvbuf[i+4])
if(recvbuf[i+1]=='b'&&recvbuf[i+2]=='o'&&recvbuf[i+3]=='d'&&recvbuf[i+4]=='y')
return 0;
else{}
else{}
i++;
}
nuno1:;
}
closesocket(m_socket);
return 0;
}
}
void rzzp(char *_2,char*_2)//get order
{
int bou,ij,ii;
char pg4[1024];
sprintf(pg4,,_1,_2);
pock(pg4,3);
ij=bou=0;
while(info2[ij]!=0)
{
while(info2[ij]!='<')
if(info2[ij]==0)
return ;
else
ij++;
if(info2[ij+1]=='p')
bou++;
else
{ij++;continue;}
if(bou>10)
{
ij+=18;
ii=ij;
while(isnum(info2[ii]))
ii++;
info2[ii]=0;
//puts(info2+ij);
//printf("bou is %d\n",bou);
switch(bou){
case 11:sscanf(info2+ij,"%d",&rs);break;
case 12:sscanf(info2+ij,"%d",&zg);break;
case 13:sscanf(info2+ij,"%d",&zd);break;
case 14:sscanf(info2+ij,"%d",&pm);return ;printf("\nrs is %d zg %d zd %d pm %d\n",rs,zg,zd,pm);
}
ij=ii+1;
}
ij++;
}
}
int getspqqz(int ij)//get score
{
int bou=0,ii;
while(info[ij]!=0)
{
while(info[ij]!='<')
if(info[ij]==0)
return ij;
else
ij++;
if(info[ij+1]=='p')
bou++;
else
{ij++;continue;}
if(bou==4)
{
ij+=18;
ii=ij;
while(info[ii]!='<')
ii++;
info[ii]=0;
strcpy(xuefen,info+ij);
ij=ii+1;}
if(bou>5)
{
ij+=18;
ii=ij;
while(isnum(info[ii]))
ii++;
info[ii]=0;
//printf("\nii %d ij %d\n",ii,ij);
switch(bou){
case 6:if(ii==ij)sc=0; else sscanf(info+ij,"%d",&sc);break;
case 7:if(ii==ij)pc=0; else sscanf(info+ij,"%d",&pc);break;


case 8:if(ii==ij)zc=0; else sscanf(info+ij,"%d",&zc);break;
case 9:if(ii==ij)mc=0; else sscanf(info+ij,"%d",&mc);break;
case 10:sscanf(info+ij,"%d",&zongc);return ij;printf("\nsc is %d pc %d zc %d mc %d zongc %d xuefen %s \n",sc,pc,zc,mc,zongc,xuefen);
}
ij=ii+1;
}
ij++;
}
return ij;
}
void format(int n)//color word
{
if(n>59)
lz(n);
else
hz(n);
}
void __(char *_1,char *_2,char *_3)
{
int i=0,ii=0;
while(info[i]!=0)
{
while(info[i]!='N')
if(info[i]==0)
return ;
else
i++;
if(strlen(info+i)<10)
break;
if(info[i+1]=='A'&&info[i+2]=='M'&&info[i+3]=='E')
{
ii=0;
while(*(info+i+19)!=' ')
_1[ii]=*(info+i+19),ii++,i++;
while(ii<8)
_1[ii]='+',ii++;
_1[ii]=0;
while(*(info+i+19)==' ')i++;
ii=0;
while(*(info+i+19)!=' ')
_2[ii]=*(info+i+19),ii++,i++;
_2[ii]=0;
while(*(info+i+19)==' ')i++;
ii=0;
while(*(info+i+19)!='"')
_3[ii]=*(info+i+19),ii++,i++;
_3[ii]=0;
i=getspqqz(i+19);
rzzp(_1,_2);
printf("\n\n");
sprintf(pmrs,"%d/%d",pm,rs);
printf("%-40s%",_3);
if(zongc>=60)
jg++;
else
bjg++;
format(zongc);
printf("%-10s",pmrs);
format(mc);
format(zc);
format(pc);
format(sc);
format(zg);
printf("        ");
format(zd);
printf("        ");
printf("%-12s",_1);
printf("%-10s\n",xuefen);
to_act++;
}
i+=7;
}
}
void initial()
{
system("C:/WINDOWS/system32/mode.com 160,35");//Auto resize window
SMALL_RECT winPon={0,0,120-1,44-1};
HANDLE con=GetStdHandle(STD_OUTPUT_HANDLE);
COORD buf={260,110};
SetConsoleWindowInfo(con,12,&winPon);
SetConsoleScreenBufferSize(con,buf);
HANDLE h=GetStdHandle(STD_OUTPUT_HANDLE);
WORD wOldColorAttrs;
CONSOLE_SCREEN_BUFFER_INFO csbiInfo;
GetConsoleScreenBufferInfo(h,&csbiInfo);
wOldColorAttrs=csbiInfo.wAttributes;
SetConsoleTextAttribute(h,BACKGROUND_GREEN|BACKGROUND_BLUE|BACKGROUND_RED);
system("cls");
time_t rawtime;struct tm * timeinfo;time ( &rawtime );timeinfo = localtime ( &rawtime );
printf ( "%4d-%02d-%02d %02d:%02d:%02d\n",1900+timeinfo->tm_year, 1+timeinfo->tm_mon,timeinfo->tm_mday,timeinfo->tm_hour,timeinfo->tm_min,timeinfo->tm_sec);
}
void verity(char *name,char*pwd)
{char pg0[1025];
int i,j;
FILE *fp=NULL;
if(fp=fopen("identity","r"))
{
fscanf(fp,"%s",name);
fscanf(fp,"%s",md5);
fscanf(fp,"%d",&for_act);
printf("for_act is %d ",for_act);
sprintf(pg0,name,md5);
pock(pg0,1);
}else{
printf("∞¥'1' to open a url to see demo,else {}\n");
switch(getch()){
case '1':system("start explorer http://hi.baidu.com/hvwatjkpmbhksve/item/7467857c165d4d01d0dcb38d");
}
fflush(stdin);
printf("Input your id:");
scanf("%s",name);
printf("\tId You had inputed is %s\t",name);
wrong:
printf("\nInput your password:");
i=0;
while((pwd[i++]=getch())!=13)putchar('*');pwd[i-1]=0;
if(*(name+3)=='8')
{if(*(name+5)=='3')
{printf("\nhello,Microelectron12\n");if(*(name+6)=='1'&&*(name+7)=='0'&&*(name+8)=='4')printf("hello, master\n");}
else if(*(name+5)=='2')
{printf("\nhello,,,,\n");if(*(name+6)=='1'&&*(name+7)=='1'&&*(name+8)=='5') printf("\tthe girl\n");}
else printf("\nWell,u\n");}
elseprintf("\nhello, student\n");
Bemd5(pwd);
sprintf(pg0,"GET /pls/wwwbks/bks_login2.uniteLogin?stuid=%s&pwd=%s HTTP/1.1\r\n"
"Host:\r\n"
"Proxy-Connection: keep-alive\r\n"
"Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8\r\n"
"User-Agent: \r\n"
"Referer:\r\n"
"Accept-Encoding: gzip,deflate,sdch\r\n"
"Accept-Language: zh-CN,zh;q=0.8\r\n"
"Accept-Charset: GBK,utf-8;q=0.7,*;q=0.3\r\n"
"Cookie: \r\n\r\n",name,md5);
pock(pg0,1);
i=j=0;
while(1){
while(info[i]!='C')i++;
if(info[i+3]==info[i+6])break;
else i++;
}
if(info[i+16]!='1'){printf("error");goto wrong;}
else
{fp=fopen("identity","w");
fprintf(fp,"%s %s ",name,md5);
fclose(fp);
system("cls");
}
}
}
void getacc(char *acc)
{
int i,j;
i=0;
while(1){
while(info[i]!='S')i++;
if(info[i+4]=='C')break;
else i++;
}
j=i;
while(info[j]!=';')j++;
info[j]=0;
strcpy(acc,info+20+i);
}
void score(char *acc){
char pg3[1024];
sprintf(pg3,acc);
puts("Getting...Waitting...");
pock(pg3,2);
puts("Success.");
gotoxy(0,4);
printf("%-40s%-10s%-10s%-10s%-10s%-10s%-10s%-18s%-18s%-10s%-10s%\n");
puts("");


gotoxy(0,5);
}
void flush(int n)
{
{
char c2[100];
int i=0;
FILE *fp=NULL;
if(fp=fopen("identity","r"))
{
while((c2[i]=getc(fp))!=' ')i++;
i++;
while((c2[i]=getc(fp))!=' ')i++;
i++;
c2[i]=0;
sprintf(c2+i,"%d ",n);
//printf("c2 is %s",c2);
fclose(fp);
fp=fopen("identity","w");
fprintf(fp,"%s",c2);
fclose(fp);
}
}
}
void shutdown(){
flush(to_act);
puts("\nFeel depressed ? Input \'1\' to shutdown,Input \'2\' to restart Computer '3' to exit:");
while(1){
switch(getch())
{
case '1':system("c:\\WINDOWS/system32/shutdown.exe -t 0 -f -s");break;
case '2':system("c:\\WINDOWS/system32/shutdown.exe -t 0 -f -r");break;
case '3':return ;
default:puts("ni an le shen me,not \'1\',not \'2\',not \'3\'!Input again:");
}
}
}
int main()
{
system("title=");
char _1[10],_2[17],_3[77],acc[20],name[12],pwd[18];
verity(name,pwd);
initial();
getacc(acc);
score(acc);
__(_1,_2,_3);
shutdown();
return 0;
}



楼猪再接再厉!
[解决办法]
vim:
gg=G
就变成这样了
[解决办法]
什么是码风?
[解决办法]
确实好了很多
[解决办法]
说实话,还是挺丑的

热点排行