标签:style http color io ar 文件 div 代码 sp
你的弟弟刚做完了“100以内数的加减法”这部分的作业,请你帮他检查一下。每道题目(包括弟弟的答案)的格式为a+b=c或者a-b=c,其中a和b是作业中给出的,均为不超过100的非负整数;c是弟弟算出的答案,可能是不超过200的非负整数,也可能是单个字符"?",表示他不会算。
1+2=33-1=56+7=?99-0=99
2
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
int main()
{
int a,b,t,k=0;
char c[5],ch;
while(~scanf("%d%c%d=%s",&a,&ch,&b,c))
{
if(!strcmp(c,"?"))
continue;
t=atoi(c);
if(ch=='+')
{
if(t==a+b)
k++;
}
else
{
if(t==a-b)
k++;
}
}
printf("%d\n",k);
return 0;
}标签:style http color io ar 文件 div 代码 sp
原文地址:http://blog.csdn.net/qq_18062811/article/details/39054645