我有几个小问题关于这个c语言程序.谁能帮我解答下?谢谢了!

#include<stdio.h>#include<conio.h>main(){chara,b,c;clrscr();printf("DoyouhaveExperien... #include<stdio.h>
#include<conio.h>
main()
{
char a,b,c;
clrscr();
printf("Do you have Experience with C? Press y/n\n");
scanf("%c",&a);
switch('a')
{
case 'N':
case 'n':printf("We are so sorry tell you...");break;
case 'Y':
case 'y':printf("What is your bachelor degree? Press y/n\n");scanf("%c",&b);
switch('b')
{
case 'N':
case 'n':printf("We are so sorry to tell you...");break;
case 'Y':
case 'y':printf("Your age less than 30? Press y/n\n");scanf("%c",&c);
switch('c')
{
case 'N':
case 'n':printf("We are so sorry to tell you...");break;
case 'Y':
case 'y':printf("Welcome join us!");
}
}
}
getch();
}
我想问下:为什么程序运行时输入一个y,要按两次回车键才退出程序?能不能按完回车后不退出程序,继续下一个问题,到最终结束问题?
可不可以做的更简单?但是必须要用switch语句.
题目如下:
.某公司的招聘条件如下:①Experience with C ②bachelor degree ③less than 30
要求屏幕输出如下:
Do you have Experience with C? Press y/n
根据应聘者输入数据逐步提问,如应聘者输入n,则提示
We are so sorry to tell you...
应聘者全满足则输出
Welcome join us!
要求必须使用switch,必须考虑用户输入大写Y或者N。
展开
 我来答
shine1991
科技发烧友

2011-11-04 · 智能家居/数码/手机/智能家电产品都懂点
知道顶级答主
回答量:4.7万
采纳率:82%
帮助的人:2.3亿
展开全部
#include<stdio.h>
#include<conio.h>
main()
{
char a,b,c;
clrscr();
printf("Do you have Experience with C? Press y/n\n");
scanf("%c",&a);
fflush(stdin);//添加,清空缓冲区
switch(a)//有错
{
case 'N':
case 'n':printf("We are so sorry tell you...");break;
case 'Y':
case 'y':printf("What is your bachelor degree? Press y/n\n");
scanf("%c",&b);
fflush(stdin);//添加,清空缓冲区
switch(b)//有错
{
case 'N':
case 'n':printf("We are so sorry to tell you...");break;
case 'Y':
case 'y':printf("Your age less than 30? Press y/n\n");
scanf("%c",&c);
fflush(stdin);//添加,清空缓冲区
switch(c)//有错
{
case 'N':
case 'n':printf("We are so sorry to tell you...");break;
case 'Y':
case 'y':printf("Welcome join us!");
}
}
}
getch();
}
更多追问追答
追问
你说有错,但是能运行啊?
追答
语法上没问题,当然能运行,但是运行结果对么!!!
程序运行后说1+1=0,难道也是对的
永星天恒
2011-11-04 · TA获得超过1203个赞
知道小有建树答主
回答量:439
采纳率:100%
帮助的人:215万
展开全部
已测试
#include<stdio.h>
#include<conio.h>
main()
{
char a,b,c;
clrscr();
printf("Do you have Experience with C? Press y/n\n");
scanf("%c",&a);
getchar();
switch(a)
{
case 'N':
case 'n':printf("We are so sorry tell you...");break;
case 'Y':
case 'y':printf("What is your bachelor degree? Press y/n\n");scanf("%c",&b);getchar();
switch(b)
{
case 'N':
case 'n':printf("We are so sorry to tell you...");break;
case 'Y':
case 'y':printf("Your age less than 30? Press y/n\n");scanf("%c",&c);getchar();
switch(c)
{
case 'N':
case 'n':printf("We are so sorry to tell you...");break;
case 'Y':
case 'y':printf("Welcome join us!");
}
}
}
getch();
}
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式