user-0 提问: C语言求助！

回复:
user: user-1
content: 引用 2 楼 weixin_46824808 的回复:[quote=引用 1 楼 5250的回复:]就是新规一个函数，在goto语句的地方调用函数而已  比如： goto test; test:    pass:  改为 int test(){     pass }  test(); 那改后的choose函数包含下面的switch 语句嘛[/quote]  你原来的choose函数是啥功能，新规的函数就是啥功能。

user: user-0
content: #include <stdio.h> #include <stdlib.h>  #include <time.h>  #include <ctype.h>  #include <string.h>  //This is a program that will help elementary school pupils practice math.   int main() { 	char fid[10],ID[10],symbol[10],convert[3],answer[10][3]; 	int j=0,i,op,n,a[10],b[10],result[10],score=0,grade,timeduation; 	FILE *data; 	time_t tstart, tend; 	 	do{ 	 printf("Please input your four digit ID number such as AB1234: "); 	 scanf("%s",ID); 	 if(!(ID[6]=='\0'&&isalpha(ID[0])&&isalpha(ID[1])&&isdigit(ID[2])&&isdigit(ID[3])&&isdigit(ID[4])&&isdigit(ID[5])))  	 printf("Sorry, invalid ID. "); }while(!(ID[6]=='\0'&&isalpha(ID[0])&&isalpha(ID[1])&&isdigit(ID[2])&&isdigit(ID[3])&&isdigit(ID[4])&&isdigit(ID[5])));//To check the ID invalidation  	choose: 	printf("\nPlease type in the number to continue.\n(1) Start a test\n(2) Check scores\n(3) Exit\n");  	scanf("%d",&op);  switch(op)//let user to choose what function they want { 	case 1: 		 getchar(); 	 printf("\n");  		 srand((unsigned)time(NULL)); 	 time(&tstart); 	 for(i=0;i<10;i++)//to start the test 	 { 				 n=rand()%4; 	 	 do{ 	 	 	a[i]=rand()%100; 	 	 	b[i]=rand()%100; 	 	 	switch(n){ 				 	case 0:symbol[i] = '+'; 						 result[i] = a[i] + b[i]; 						 break; 					 case 1:symbol[i] = '-'; 						 result[i] = a[i] - b[i]; 						 break; 				 	case 2:symbol[i] = '*'; 						 result[i] = a[i] * b[i]; 				 		 break; 				 	case 3:symbol[i] = '/'; 						 result[i] = a[i] / b[i]; 	 	 	} 				 }while(result[i] > 99 || result[i] < 0 || n==3 && a[i] % b[i] != 0); 				 printf("%2d %c %2d = ", a[i], symbol[i], b[i]); 			 	 itoa(result[i], convert, 10); 				 gets(answer[i]);//gather the user's answers 				 if (!strcmp(convert, answer[i])) { 				 score += 10; } 	 } 			 time(&tend);//time ends 			 printf("\nYou have got %d score(s) in %ld seconds!\n",score,tend-tstart);  		 printf("Prob. | Correct Answ. | Ur Answ\n"); //print the test information 		 for(i=0;i<10;i++) 		 { 		 	printf("(%2d) %2d %c %2d = %3d %s\n",i+1,a[i],symbol[i],b[i],result[i],answer[i]); 		 }  		 data = fopen("record.txt", "a+");  		 fprintf(data,"%s %3d %3ld\n",ID,score,tend-tstart);  		 fclose(data); 		 goto choose; 		 break;  	 case 2: data=fopen("record.txt","r"); if(data==NULL) { 	printf("You have never done the test before."); 	goto choose; } fscanf(data,"%s %d %d",fid,&grade,&timeduation);//scan the user's information printf("Your previous records are:\n"); while(!feof(data)) { 	 if(strncmp(ID,fid,6)==0)//check the user's name { 	 printf("%s %d %d \n\n",fid,grade,timeduation); 	 j=1; } fscanf(data,"%s %d %d",fid,&grade,&timeduation); }  if(j==0)  { 			 printf("Sorry, there is no previous record.\n"); } fclose(data); 			 goto choose;  	 	 break; 	 	case 3: 		 printf("It's about to quit! \n");  			 break; //quit 	default: 		 printf("Wrong Number! "); 	 goto choose; } return 0; }

user: user-2
content: 建议直接贴代码而不是贴图片～

user: user-0
content: 引用 1 楼 5250的回复:就是新规一个函数，在goto语句的地方调用函数而已  比如： goto test; test:    pass:  改为 int test(){     pass }  test(); 那改后的choose函数包含下面的switch 语句嘛

user: user-1
content: 就是新规一个函数，在goto语句的地方调用函数而已  比如： goto test; test:    pass:  改为 int test(){     pass }  test();