View Code of Problem 95

#include<string.h>
#include<stdio.h>
#include<math.h>
struct ppp{//不需要加括号 
	char name[20];
	char sex[5];
	int year;
	int month;
	int date;
}stu[100];
int main(){
	int i=0,j = 0,k;
	char s[20];
	char name[20];
	char sex[5];
	while(scanf("%s",s)!=EOF){
		if(strcmp(s,"add")==0){
			scanf("%s %s %d %d %d",stu[i].name,stu[i].sex,&stu[i].year,&stu[i].month,&stu[i].date);
			i++;
		}
		else if(strcmp(s,"name")==0){
			scanf("%s",name);
			for(j=0;j<=i;j++){
				if(strcmp(name,stu[j].name)==0){
					printf("%s %s %d %d %d",stu[j].name,stu[j].sex,stu[j].year,stu[j].month,stu[j].date);
				}
			}	
		}
		else if(strcmp(s,"sex")==0){
			scanf("%s",&sex);
			for(j=0;j<=i;j++){
				if(strcmp(name,stu[j].sex)==0){
					printf("%s %s %d %d %d",stu[j].name,stu[j].sex,stu[j].year,stu[j].month,stu[j].date);
				}
			}	
		}

		else if(strcmp(s,"quit")==0){
			break;
		}
	}
	return 0;
}







Double click to view unformatted code.


Back to problem 95