标题:为什么最后的一个scanf不能被执行
取消只看楼主
kennyzhang
Rank: 1
等 级:新手上路
帖 子:41
专家分:0
注 册:2006-7-24
 问题点数:0 回复次数:2 
为什么最后的一个scanf不能被执行
#include<stdio.h>
#include<dos.h>
main()
{
float k1,k2,k3;
char a1,b2='Y';
int d;

clrscr();
printf("******************** Welcome to this learning system ***************************");


do
{
printf("please enter k1,a1,k2:");
scanf("%f,%c,%f",&k1,&a1,&k2);
printf("please enter your answer:");
scanf("%f",&k3);
//***************************************************************************************************

switch(a1)
{
case '+':if(k3==(k1+k2)) d=1;
else
d=0;
break;
case '-':if(k3==(k1-k2)) d=1;
else
d=0;
break;
case '*':if(k3==(k1*k2)) d=1;
else
d=0;
break;
case '/':if(k2==0)
{
printf("input error!\n");
d=0;
break;
}
else
{
if(k3==(k1/k2)) d=1;
else
d=0;
}
break;

default: printf("input error!\n");

}

if(d)

{
printf("You are great!");
}
else
{
printf("please try again!");
}

printf("do you want to go on? (Y on N)\n");

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~下面的都不能执行了 为什么?????
scanf("%c",&b2);
}while((b2=='Y')||(b2=='y'));

}

程序可以执行到printf("do you want to go on? (Y on N)\n");

后面的scanf("%c",&b2);不能执行
搜索更多相关主题的帖子: scanf printf please 
2006-09-08 10:35
kennyzhang
Rank: 1
等 级:新手上路
帖 子:41
专家分:0
注 册:2006-7-24
得分:0 
不可以呀 程序运行到 printf("do you want to go on? (Y on N)\n") 就自动关闭了 我在Turbo c3.0下写的

/--------------------------------------------------------------------- 世界与我同步。
2006-09-08 10:59
kennyzhang
Rank: 1
等 级:新手上路
帖 子:41
专家分:0
注 册:2006-7-24
得分:0 
谢谢 楼上的 好了
对了 nuciewth 你收徒弟吗?


/--------------------------------------------------------------------- 世界与我同步。
2006-09-08 12:04



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-88795-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 2.026863 second(s), 8 queries.
Copyright©2004-2025, BCCN.NET, All Rights Reserved