#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);不能执行