#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 人评分
C语言训练-求素数问题 (C语言代码)浏览:722 |
C语言程序设计教程(第三版)课后习题11.1 (C语言代码)浏览:687 |
简单的a+b (C语言代码)浏览:596 |
C语言程序设计教程(第三版)课后习题1.5 (C语言代码)浏览:460 |
星期判断机 (C语言代码)浏览:859 |
DNA (C语言代码)浏览:747 |
简单的a+b (C语言代码)浏览:946 |
C语言程序设计教程(第三版)课后习题9.4 (C语言代码)浏览:636 |
格式化数据输出 (C语言代码)浏览:817 |
C语言程序设计教程(第三版)课后习题6.7 (C语言代码)浏览:672 |