UVa 11332 - Summing Digits
来源:互联网 发布:java的mvc框架详解 编辑:程序博客网 时间:2024/05/29 10:35
题目:计算一个数字各个位上的数字和,如果不小于10就再次计算,直到小于10。
分析:简单题。直接计算即可。
#include <iostream>#include <cstdlib>#include <cstring>#include <cstdio>using namespace std;int main(){char temp[1005];while ( cin >> temp ) {int sum = 0,count;int len = strlen(temp);if ( temp[0] == '0' && len == 1 ) break;for ( int i = 0 ; i < len ; ++ i )sum += temp[i] - '0';while ( sum > 9 ) {count = 0;while ( sum ) {count += sum%10;sum /= 10;}sum = count;}cout << sum << endl;}return 0;}
- UVa 11332 - Summing Digits
- UVa 11332 Summing Digits (water ver.)
- 11332 - Summing Digits
- uva 112 Tree Summing
- uva 112 - Tree Summing
- uva 112 - Tree Summing
- UVa 112 - Tree Summing
- uva 112 - Tree Summing
- uva 112 Tree Summing
- UVA 112 Tree Summing
- UVa 112 - Tree Summing
- UVa 112 - Tree Summing
- UVa 112 - Tree Summing
- uva 112 - Tree Summing
- uva-112 Tree Summing
- UVA 112 Tree Summing
- UVA 112 Tree Summing
- UVa 112 Tree Summing
- 解决使用SQLServer2008R2的“sp_send_dbmail”发邮件,当邮件标题、内容中有中文时就会变成“?”的问题
- JSP概念
- JSP的错误页面设置和页面跳转等
- "Introduction to the Theory of Computation" 1st round done ROUGHLY
- UVa 439 - Knight Moves
- UVa 11332 - Summing Digits
- OpenJDK源码研究笔记(六)--观察者模式工具类(Observer和Observable)和应用示例
- 奇怪的问题
- MySQL安装配置汇总(二)
- IOS7 图标尺寸
- 我读过的100+本经典书籍(持续更新,上次更新2013年11月15日)
- MFC 中 CFileDialog 的 m_ofn (OPENFILENAME) 参数详解
- 短址原理及其实现
- Windows Server 2008 显示图片缩略图