#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语言代码)浏览:506 |
C语言程序设计教程(第三版)课后习题11.5 (C语言代码)浏览:1534 |
2003年秋浙江省计算机等级考试二级C 编程题(2) (C语言代码)浏览:541 |
【绝对值排序】 (C++代码)浏览:672 |
ASCII帮了大忙浏览:749 |
数组输出 (C语言代码)--此题的题目描述有问题浏览:1817 |
2003年秋浙江省计算机等级考试二级C 编程题(2) (C语言代码)浏览:674 |
C语言程序设计教程(第三版)课后习题10.7 (C语言代码)浏览:546 |
淘淘的名单 (C语言代码)浏览:1104 |
WU-复数求和 (C++代码)浏览:2015 |