C语言循环结束后怎么询问是否继续?很急~

来源:百度知道 编辑:UC知道 时间:2024/06/08 03:41:13
这样一个输入学生号查找记录的一段代码,怎么加点语句让他能在执行完之后再问一下“是否继续?”若“是”再执行查找,“否”返回主函数~
谢谢~很着急~
代码如下:
int i=0,k=0;
char inputID[10];
printf("Please Input the Student ID of the record to be displayed: ");
scanf("%s",inputID);
for(i=0;i<count-1;i++)
{
if(strcmp(inputID,stud[i].stuID)==0)
{ printf("\nStudent's Record as Follows: \n");
printf("%s %-10s %-3d %-6.1f\n",
stud[i].stuID,stud[i].name,stud[i].age,stud[i].score);
k=1;
}
}
if(k==0)
printf("No Such Record Found!\n");
不行啊~楼下的代码还是运行不了,出现“Continue?”之后根本没有从输入的机会,直接回主目录了~~

int i=0,k=0;
char inputID[10],IsOther,Temp[10];
do
{
printf("Please Input the Student ID of the record to be displayed: ");
scanf("%s",inputID);
gets(Temp);/*回收scanf后面的回车用的*/
for(i=0;i<count-1;i++)
{
if(strcmp(inputID,stud[i].stuID)==0)
{ printf("\nStudent's Record as Follows: \n");
printf("%s %-10s %-3d %-6.1f\n",
stud[i].stuID,stud[i].name,stud[i].age,stud[i].score);
k=1;
}
}
if(k==0) printf("No Such Record Found!\n");
printf("Are you going to Input?(Y/N)");
IsOther=getch();
}while(IsOther=='Y'||IsOther=='y');

直接用DO。。。whlie...把你的框在里面啊。。
do
{"你的"
printf("YorN.....")
scanf(%c,x)
}
while x=Y
人懒。不好意思。

int i=0,k=0;
char inputID[10];
char goOn;// 指示是否继续
while(1){

printf("Please Input