Digital Roots
来源:互联网 发布:python counter 详解 编辑:程序博客网 时间:2024/05/17 03:29
输入的超过了int的范围,要用字符串解决
http://acm.hdu.edu.cn/showproblem.php?pid=1013
#include <cstdio>
#include <cstring>
char ch[10000];
int main()
{
while(scanf("%s",ch)!=EOF&&ch[0]!='0'){
int len=strlen(ch),ans=0;
for(int i=0;i<len;i++){
ans+=ch[i]-'0';
if(ans>=10)ans=ans%10+ans/10;
}
printf("%d\n",ans);
}
}
0 0
- Digital Roots
- Digital Roots
- Digital Roots
- Digital Roots
- Digital Roots
- Digital Roots
- Digital Roots
- Digital Roots
- Digital Roots
- Digital Roots
- Digital Roots
- Digital Roots
- Digital Roots
- Digital Roots
- Digital Roots
- Digital Roots
- Digital Roots
- Digital Roots
- 消耗内存
- adb连接Android 4.2.2版本手机时出现offline或unauthorized问题的解决方法
- SolrException: Index locked 和 Error opening new searcher 最终解决方案
- EMC单片机宏定义学习手记
- 欢迎使用CSDN-markdown编辑器
- Digital Roots
- JavaScript打开新窗口时POST传参
- THRDTERM-----干净地结束一个线程
- input 框中值固定 只可以输入数字 不能回格掉初始值
- iOS设备上的App设计规范
- Eclipse中安装subclipse插件
- exec函数
- .a文件的添加
- Qt5 设置QLabe中字体的颜色