#include <stdio.h> struct studen {int xuehao; char name[20]; char kecheng[20]; int nian; }xuesheng[5]; void chushihua(void); void nian(void); void id(void);
main() { char ch; chushihua(); while(1) { clrscr(); printf("\nA.yong nian fen cha xun xin xi.\nB.yong ID cha xun xin xi.\nC.tui chu xi tong.\nqing shu ru xuan xiang hui che que ren:"); scanf("%c",&ch); switch (ch) { case 'a': case 'A': nian(); break; case 'b': case 'B': id(); break; case 'c': case 'C': exit(0); break; default: printf("\nshu ru cuo wu qing chong xin shu ru "); } } } void chushihua() { int i; clrscr(); for(i=0;i<5;i++) { printf("\nshu ru di %d ge xue sheng de xue hao :",i+1); scanf("%d",xuesheng[i].xuehao); printf("\nshu ru di %d ge xue sheng de xing ming :",i+1); scanf("%s",xuesheng[i].name); printf("\nshu ru di %d ge xue sheng de ke cheng :",i+1); scanf("%s",xuesheng[i].kecheng); printf("\nshu ru di %d ge xue sheng ru xue nian fen:",i+1); scanf("%d",xuesheng[i].nian); } return; } void nian() { int ntem,i,x=1; char chtem; clrscr(); printf("\nshu ru yao cha xun de nian fen"); scanf("%d",&ntem); printf("\ncha xun jie gu"); for(i=0;i<5;i++) { if(xuesheng[i].nian==ntem) { printf("\n%d.xue sheng xue hao :%d",x,xuesheng[i].xuehao); printf("\n xue sheng ming zi :%s",xuesheng[i].name); printf("\n xue sheng ke cheng :%s",xuesheng[i].kecheng); printf("\n xue sheng ru xue nian fen:%d",xuesheng[i].nian); x++; } } printf("\nji xu qing an \"y\"tui chu qing an\"n\" "); scanf("%c",&chtem); if(chtem=='y'||chtem=='Y') return; else exit(0); } void id() { int xtem,i,x=1; char chtem; clrscr(); printf("\nshu ru yao cha xun de nian fen"); scanf("%d",&xtem); printf("\ncha xun jie gu"); for(i=0;i<5;i++) { if(xuesheng[i].xuehao==xtem) { printf("\n%d.xue sheng xue hao :%d",x,xuesheng[i].xuehao); printf("\n xue sheng ming zi :%s",xuesheng[i].name); printf("\n xue sheng ke cheng :%s",xuesheng[i].kecheng); printf("\n xue sheng ru xue nian fen:%d",xuesheng[i].nian); x++; } } printf("\nji xu qing an\"y\"tui chu qing an\"n\""); scanf("%c",&chtem); if(chtem=='y'||chtem=='n') return; else exit(0); }