online_judge_1143
2015-12-23 19:29
218 查看
#include <iostream> #include <cstring> #include <cstdio> using namespace std; int main() { char str1[12],str2[12]; int ans,len1,len2; int i,value; while(scanf("%s%s",str1,str2)!=EOF) { if(strcmp(str1, "0")==0 && strcmp(str2, "0")==0) break; ans = 0; value = 0; len1 = strlen(str1); len2 = strlen(str2); for(i=1; i<=len1 && i<=len2; ++i) { if((str1[len1-i]+str2[len2-i]+value-'0'-'0')>9) { value = 1; ans++; } } while(i<=len1) { if((str1[len1-i]+value-'0')>9) { value = 1; ans++; } ++i; } while(i<=len2) { if((str2[len2-i]+value-'0')>9) { value = 1; ans++; } ++i; } if(ans > 1) { printf("%d carry operations.\n",ans); } else if(ans == 1) { printf("%d carry operation.\n",ans); } else { printf("NO carry operation.\n"); } } return 0; }
细节很重要……operations和operation很关键。。。
operations
operations
相关文章推荐
- 【iOS开发-1】AppIcon图标的尺寸,绘制,命名规则以及怎么回到HOME界面查看效果?
- AndroidStudio中包冲突问题(使用解析和Multidex重复条目)
- [Cocoa]_[初级]_[NSNotificationCenter 消息中心在程序中的具体应用]
- 文章标题
- LeetCode之Array题目汇总
- Unity3D Animator 动态添加事件回调和替换动画
- Bloom Filter算法实现
- C#正则表达式
- Xcode升级后,遇到的告警和解决方法
- 督主cocos2d学习笔记
- 一元多项式化简
- OpenCV的一些基础知识
- 适配器模式(Adapter)—山下的养牛场
- CentOS根分区扩容方法
- iOS完全自学手册——[一]Ready?No!
- 2015-12-23日记:稳步的走向稳定与互联网加教育的理念阐述
- IOS开发之MapKit学习笔记
- Xen 和 KVM 下如何关闭 virbr0
- SQL Server完全删除问题
- Objective-C:@class和#import