帮忙看下这个程序要怎么循环

来源:百度知道 编辑:UC知道 时间:2024/05/21 09:17:52
#include<stdio.h>
void main()
{
one:
char chse;
int count=0;
puts("\t********机票系统*********");
puts("1、预定");
puts("2、查询");
puts("3、退出");
printf("请选择:");
scanf("%c",&chse);
while(0==count)
{
count++;
switch(chse)
{
case '1':printf("\n预定代码\n");goto one;
case '2':printf("\n查询代码\n");goto one;
case '3':printf("\n退出代码\n");break;

}
}
}//没办法循环执行啊,怎么改?

你的程序想做什么的。要实现什么功能。
帮你改了一下。不知道你否你想要的效果

#include<stdio.h>
void main()
{

char chse;
int count=0;
while(0==count)
{
puts("\t********机票系统*********");
puts("1、预定");
puts("2、查询");
puts("3、退出");
printf("请选择:");
scanf("%c",&chse);

switch(chse)
{
case '1':printf("\n预定代码\n");count++;break;
case '2':printf("\n查询代码\n");count++;break;
case '3':printf("\n退出代码\n");count++;break;

}
}
}

这句
scanf("%c",&chse);
改成
scanf("%d",&chse);
以数的形式输入,不要以字符,不然回车也会作为一个字符输入到chse中

这样的话,switch中的那几个case后的单引号也去掉