user-0 提问: 接受批评，码风焕然一新

回复:
user: user-1

user: user-2
content: 请判断所有scanf类函数的返回值！ http://bbs.csdn.net/topics/390471779

user: user-3
content: 搞个astyle搞一搞

user: user-4
content: 引用 34 楼 ForestDB 的回复:void hz(int n)//print red  word { } void lz(int n)//print green word { } print_red(int n) print_green(int n)多好，注释都省了  print(int n, int color)多好，xx都省了 +1  好的命名胜过一堆注释

user: user-5
content: 注意换行，以及{} !

user: user-6
content: void hz(int n)//print red  word { } void lz(int n)//print green word { } print_red(int n) print_green(int n)多好，注释都省了  print(int n, int color)多好，xx都省了

user: user-6
content: 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; } ctype中有个函数叫isdigit?

user: user-7
content: 楼主你这代码看着头疼 。。

user: user-8
content: case里头代码段太长。不过说实话，代码风格什么的，要以同一个组织或者同一个项目的规范为标准，不要玩个人风格。

user: user-9

user: user-10
content: 撸主不觉得缩进有点太多吗？  看得累的慌~~~~~~~~

user: user-11
content: 函数的实现之间能不能加些空行啊！看着太费劲了！

user: user-12
content: default:puts("ni an le shen me,not \'1\',not \'2\',not \'3\'!Input again:");

user: user-13
content: 我觉得switch语句中最好还是把default给加上吧，将来调试也方便

user: user-14
content: 10个可用分...

user: user-15
content: 很多内部while,或者switch都完全可以修改成函数. 一个函数行数不要太长.  line 20  可优化. line 35 函数参数不能直观表达意义.  并且 char[]与char*混用了. line 63 与 line 89 while可修改成函数 ....还有不少.  当看内部那么多while就感觉有点那个什么?  还有, 我是那种有点 {}强迫证的. 没有它, 不容易一眼看出功能代码块.  不同的功能连续代码块之间最好也能有空行区分.

user: user-16
content: 看起来还不错啊，不过有些缩进还是没有，是不是用astyle格式化一下会好点。

user: user-17
content: 依然是可读性还不够，给你用indent格式化了一下，好看多了  /*  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"); 		} else 			printf("\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); 		} 	} }

user: user-18
content: 看着挺舒服的

user: user-19
content: 这段代码是拼凑，抄袭的代码吧，包含好几种书写风格