----------------解决方案--------------------------------------------------------
你要把程序贴出来啊,你这个问题和程序有关系
----------------解决方案--------------------------------------------------------
#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); }
----------------解决方案--------------------------------------------------------
源程序在那个nian函数里的scanf("%c",&chtem);那里每次都不让输入 打两行scanf才行
----------------解决方案--------------------------------------------------------
没人知道??????????????????
----------------解决方案--------------------------------------------------------
好烂的程序...
我是你就重新写一个....
----------------解决方案--------------------------------------------------------
如题,为什么scanf要打两次才能输入 烂不烂没关系
----------------解决方案--------------------------------------------------------
置顶贴,《scanf()函数释凝》下
----------------解决方案--------------------------------------------------------
怎么一点格式都没有呢
----------------解决方案--------------------------------------------------------
在那个板块置顶的啊
----------------解决方案--------------------------------------------------------