tips:分析不够仔细,白费了许多功夫。输入数据的范围,平时几乎很少考虑的,这个以后得注意。代码检查不够仔细啊,以后得注意了
#include<iostream>
using namespace std;
void main()
{
int n=0,sum=0;
char s[1000];
while(cin>>s)
{
n=0;
sum=0;
if(strcmp(s,"0")==0)
break;
int len=strlen(s);
for(int i=0;i<len;i++)
{
n+=s[i]-'0';
}
while(n>9)
{
sum=0;
while(n!=0)
{
sum+=n%10;
n/=10;
}
n=sum;
}
cout<<n<<endl; }
}

Problem : 1013 ( Digital Roots )的更多相关文章

  1. HDU 1013 Digital Roots(to_string的具体运用)

    传送门:http://acm.hdu.edu.cn/showproblem.php?pid=1013 Digital Roots Time Limit: 2000/1000 MS (Java/Othe ...

  2. HDU 1013 Digital Roots【字符串,水】

    Digital Roots Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Tot ...

  3. HDU 1013 Digital Roots(字符串)

    Digital Roots Problem Description The digital root of a positive integer is found by summing the dig ...

  4. HDU 1013.Digital Roots【模拟或数论】【8月16】

    Digital Roots Problem Description The digital root of a positive integer is found by summing the dig ...

  5. HDU 1013 Digital Roots(字符串,大数,九余数定理)

    Digital Roots Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Tot ...

  6. HDU 1013 Digital Roots 题解

    Problem Description The digital root of a positive integer is found by summing the digits of the int ...

  7. 杭电 1013 Digital Roots

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1013 反思:思路很简单,但是注意各位数加起来等于10的情况以及输入0的时候结束程序该怎么去表达 #in ...

  8. hdu 1013 Digital Roots

    #include <stdio.h> int main(void) { int m,i;char n[10000]; while(scanf("%s",&n)= ...

  9. 解题报告:hdu1013 Digital Roots

    2017-09-07 22:02:01 writer:pprp 简单的水题,但是需要对最初的部分进行处理,防止溢出 /* @theme: hdu 1013 Digital roots @writer: ...

随机推荐

  1. Mybatis学习之道(一)

    本例子为采用的mysql+maven+mybatis构建. 初步学习mybatis: mybatis为一个半自动框架,相对于hibernate来说他更加轻巧,学习成本更低. 1.新建一个maven工程 ...

  2. 用batch调用DB2 CLPPlus执行多个SQL文

    不啰嗦直接上技能. 大概三部分组成: 1.bat文件.(run.bat) 2.辅助SQL文.(AllRun.sql) 3.要执行的SQL文.(S1.sql,S2.sql,S3.sql) +++++++ ...

  3. 高并发关于微博、秒杀抢单等应用场景在PHP环境下结合Redis队列延迟入库

    第一步:创建模拟数据表. CREATE TABLE `test_table` ( `id` int(11) NOT NULL AUTO_INCREMENT, `uid` int(11) NOT NUL ...

  4. Java爬虫----有道翻译初步

    目标:http://fanyi.youdao.com/ 用爬虫实现翻译功能. 利用f12查看网页Network,可以发现 有关翻译的表单请求通过  http://fanyi.youdao.com/tr ...

  5. 计蒜客 数字解码 dp

    思路:dp(i)表示前i个字符的解码方案种数.进行状态转移时需要仔细思考,分情况讨论: 设第i个字符和第i-1个字符组成的数为x. 1.如果x根本不可能出现说明不是合理的编码,直接使dp(i)为0,例 ...

  6. Spring cloud oauth2.0 access_token 永不失效设置方法

    在AuthorizationServerConfigurerAdapter,重写一个TokenServices,注意这里的@Primary 非常重要,否则会有3个同类型的Bean,无法注入,会抛出以下 ...

  7. shell脚本基础1 概述及变量

    shell概述:在linux内核与用户之间的解释器程序通常指/bin/bash负责指向内核翻译及传达用户/程序指令相当于操作系统的"外壳" shell的使用方式:交互式--命令行: ...

  8. AutoMapper 使用心得

    在很久之前就已经有了解到AutoMapper 这一个组件了,但是却一直不明白这个东西要怎么使用,是用来干什么的.经过几经周折之后,看了资料大概5.6次吧,总算理解其中的用途和原理(请原谅我理解能力太差 ...

  9. 第1章 PCI总线的基本知识

    PCI总线作为处理器系统的局部总线,主要目的是为了连接外部设备,而不是作为处理器的系统总线连接Cache和主存储器.但是PCI总线.系统总线和处理器体系结构之间依然存在着紧密的联系. PCI总线作为系 ...

  10. R︱高效数据操作——data.table包(实战心得、dplyr对比、key灵活用法、数据合并)

    每每以为攀得众山小,可.每每又切实来到起点,大牛们,缓缓脚步来俺笔记葩分享一下吧,please~ --------------------------- 由于业务中接触的数据量很大,于是不得不转战开始 ...