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. 函数重载overload

    与void show(int a, char b, double c){}构成重载的有: a) void show(int x, char y, double z){} //no b) int sho ...

  2. 微信小程序半周问题总结

    新产品要做一个微信小程序,不想吐槽老板没给任何准备就给出了需求和原型图,好像默认小程序闭着眼睛就可以很顺利开发好.现在半周下来(五一结束开始到今天)完成了差不多所有的界面,网络请求部分还跟服务端兄弟耗 ...

  3. spring 配置文件无法加载,junit找不到xml配置文件java.lang.IllegalStateException: Failed to load ApplicationContext

    最近遇到一个奇怪的问题.maven项目再进行junit单元测试的时候发现无法加载配置文件.一会能加载一会又不能加载.然后试了在src/main/resource下面的配置文件放到src/test/re ...

  4. 恢复Mysql丢失的root用户权限

      今天安装了某个程序时, 由于程序很傻X的 新建了一个 root@localhost 用户 并把 root权限全部改为了 no 这下 我也 傻X 了.服务器上所有程序都崩溃了. 此时即使用root用 ...

  5. 左连接条件与where条件的区别

    Sql 查询语句应用左连接时的链接条件中经常加一些常量值在里面如: "On a.id= b.id and b.is_del =0 and b.is_old =1" 这种条件如果加在 ...

  6. 项目使用EntityFramework需要做的几项工作

    1..新项目引用创建好的其他项目,比如实体类库.数据库业务.实体数据模型等需要用到的项目进行引用. 2.新项目使用NuGet获取AutoMapper和EntityFramework程序包进行安装引用, ...

  7. R语言︱SNA-社会关系网络—igraph包(中心度、中心势)(二)

    每每以为攀得众山小,可.每每又切实来到起点,大牛们,缓缓脚步来俺笔记葩分享一下吧,please~ --------------------------- SNA社会关系网络分析中,关键的就是通过一些指 ...

  8. HI3531网络tftp、nfs加载

     ifconfig eth0 hw ether 00:00:23:34:45:66; ifconfig eth0 192.168.1.10 netmask 255.255.255.0; route a ...

  9. FusionCharts报错

    1.具体报错如下 SCRIPT 5007:无法获取属性"SetReturnValue"的值: 对象为空或未定义 script block(158),行1字符158 2.错误原因 3 ...

  10. MPEG2_TS流基本概念和数据结构

    时对应network_PID,program_number等于其它值时对应program_map_PID. (3)PMT   PMT数据结构如下: TS_program_map_section(){ ...