我有几个小问题关于这个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。 展开
#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。 展开
2个回答
展开全部
#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();
}
#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,难道也是对的
展开全部
已测试
#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();
}
#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();
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询