C语言实现给小学生出加法考试题:
我的出现死循环
题目:
我的代码:
#include<stdio.h>
int Add(int a, int b){
int answer;
printf("%d+%d=",a,b);
scanf("%d",&answer);
if(a+b == answer)
return 1;
else
return 0;
}
void print(int flag){
if(flag)
printf("Rright!\n");
else
printf("Not correct. Try again!\n");
}
int main(){
int a,b,answer,s;
printf("Input a,b:");
scanf("%d,%d",&a,&b);
s=Add(a,b);
while(1){
if(s==1){
print(1);
break;
}
if(s==0){
print(0);
}
}
return 0;
}