#include <stdio.h> #include <string.h> #include <math.h> //1073 int main() { int a,b,result = 0,count = 0; char c[4]={'0','0','0','\0'},s,s1; while(scanf("%d%c%d%c%s",&a,&s,&b,&s1,&c)!= EOF) { int i,length; if(s == '?') continue; length = strlen(c); for(i=0;i<length;i++) { result += (c[i]-'0')*(int)pow(10,length-1-i); //注意pow返回值类型为double } if(s == '+') { if(result == a+b) count++; } else { if(result == a-b) count++; } //注意恢复数据初值,为下次计算准备 for(i=0;i<3;i++) { c[i]='0'; } result = 0; } printf("%d",count); while(1); return 0; }
0.0分
0 人评分
点我有惊喜!你懂得!浏览:1323 |
C语言训练-计算t=1+1/2+1/3+...+1/n (C语言代码)浏览:491 |
C语言程序设计教程(第三版)课后习题3.7 (C++代码)浏览:985 |
C语言程序设计教程(第三版)课后习题10.3 (C语言代码)浏览:682 |
不知道哪里错了浏览:1139 |
C语言程序设计教程(第三版)课后习题11.5 (C语言代码)浏览:612 |
C语言考试练习题_排列 (C语言代码)浏览:717 |
C语言程序设计教程(第三版)课后习题6.10 (C语言代码)浏览:1050 |
WU-输出九九乘法表 (C++代码)浏览:1650 |
WU-判定字符位置 (C++代码)浏览:1395 |