题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1013

反思:思路很简单,但是注意各位数加起来等于10的情况以及输入0的时候结束程序该怎么去表达

#include<stdio.h>
#include<string.h>
char a[1000000];
int main()
{
int i;
int sum=0;
while(gets(a)&&a[0]!='0')
{
sum=0;
for(i=0;a[i]!='\0';i++)
sum+=a[i]-'0';
while(sum>=10)
{
sum=sum/10+sum%10;
}
printf("%d\n",sum);
}
}

  

杭电 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. hdu 1013 Digital Roots

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

  8. Problem : 1013 ( Digital Roots )

    tips:分析不够仔细,白费了许多功夫.输入数据的范围,平时几乎很少考虑的,这个以后得注意.代码检查不够仔细啊,以后得注意了 #include<iostream> using namesp ...

  9. 解题报告:hdu1013 Digital Roots

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

随机推荐

  1. eas之新建窗口

    public void actionObjectProp_actionPerformed(ActionEvent e)          throws Exception {     UIContex ...

  2. Linux启用ftp服务及连接

    虚拟机的系统是centos6.3 第一步.启动ftp service vsftpd restart 提示 vsftpd: 未被识别的服务 解决方法是升级vsftpd服务 yum install vsf ...

  3. python第十周:进程、协程、IO多路复用

    多进程(multiprocessing): 多进程的使用 multiprocessing是一个使用类似于线程模块的API支持产生进程的包. 多处理包提供本地和远程并发,通过使用子进程而不是线程有效地侧 ...

  4. 【Zoj 4061】Magic Multiplication

    [链接] 我是链接,点我呀:) [题意] [题解] /* for a[1] from 1~9 1*1=1 2*1=2 3*1=3 1*2=2 2*2=4 3*2=6 1*3=3 2*3=6 3*3=9 ...

  5. fzu 2087并查集的运用求最小生成树的等效边

    //对数组排序后,对于边相同并且边的两端不在一个集合内的一定是等效边或者必加边, //第一数数,第二合并集合 #include<stdio.h> #include<stdlib.h& ...

  6. 【翻译自mos文章】ABMR:在asm 环境中測试Automatic Block Recover 特性的方法

    ABMR:在asm 环境中測试Automatic Block Recover 特性的方法 參考原文: ABMR: How to test Automatic Block Recover Feature ...

  7. TestNG升级

    TestNG 6.5.1 or above is required,please update your TestNG or uncheck 'Use project TestNG jar' from ...

  8. Linux命令(三)——用户、群组管理命令

    一.用户和群组的配置文件 1./etc/passwd文件 该文件存储了所有用户的一些基本属性. /etc/passwd文件中所存信息的具体含义如下: 用户名:x表示必须使用密码登录:uid用户标识符: ...

  9. session 的工作原理

    session.cookie_domain session.cookie_path session.name session.save_path session.use_cokies session_ ...

  10. 网页设计——Dreamweaver

    在看ASP.NET视频时,讲到了一款编写HTML代码的软件--Dreamweaver.它是一款专门进行网页设置的软件.通过它能够设计出多彩的界面,相对于vs中自带的设计方式来说,他不须要知道太多的技术 ...