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. Spring context:property-placeholder 一些坑

    今天在配置多配置文件的时候偶然发现如果我使用   <context:property-placeholder location="classpath:filePath.properti ...

  2. 第二十二章 Django会话与表单验证

    第二十二章 Django会话与表单验证 第一课 模板回顾 1.基本操作 def func(req): return render(req,'index.html',{'val':[1,2,3...]} ...

  3. python小练习之读取文件写入excel

    文件是个json文件 内容为: 导入excel后的格式为 屡一下思路 一步步怎么实现: 1 首先需要读取json文件 然后将读取的内容转为字典 2 将excel的列名写入一个list中 然后遍历执行写 ...

  4. redis分布式锁的几种实现方式,以及Redisson的配置和使用

    最近在开发中涉及到了多个客户端的对redis的某个key同时进行增删的问题.这里就会涉及一个问题:锁 先举例在分布式系统中不加锁会出现问题: redis中存放了某个用户的账户余额 ,例如100 (用户 ...

  5. Web渗透测试笔记(基础部分)

    信息收集: dns信息收集 格式:dns... -参数 域名 -参数 示例: root@xxSec:~# dnsenum baidu.com root@xxSec:~# dnsenum -f dns. ...

  6. caffe+GPU︱AWS.G2+Ubuntu14.04+GPU+CUDA8.0+cudnn8.0

    国服亚马逊的GPU实例G2.2xlarge的python+caffe的安装过程,被虐- 一周才装出来- BVLC/caffe的在AWS安装的官方教程github: https://github.com ...

  7. spring schedule定时任务(二):配置文件的方式

    接着上一篇,这里使用spring配置文件的方式生成spring定时任务. 1.相应的web.xml没有什么变化,因此便不再罗列.同样的,相应的java代码业务逻辑改动也不大,只是在原来的基础上去掉@C ...

  8. 【mysql】mysql内置函数

    mysql常用内置函数 1.mysql字符串函数 contact 字符串连接函数 mysql>select contact("he",'llo');# hello lcase ...

  9. FusionWidgets Bulb图

    1.数据源提供 Bulb.xml: <?xml version="1.0" encoding="UTF-8"?> <chart lowerLi ...

  10. HighCharts之2D饼图

    HighCharts之2D饼图 1. HighCharts之2D饼图源码 <!DOCTYPE html> <html> <head> <meta charse ...