杭电 1013 Digital Roots
题目链接: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的更多相关文章
- HDU 1013 Digital Roots(to_string的具体运用)
传送门:http://acm.hdu.edu.cn/showproblem.php?pid=1013 Digital Roots Time Limit: 2000/1000 MS (Java/Othe ...
- HDU 1013 Digital Roots【字符串,水】
Digital Roots Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Tot ...
- HDU 1013 Digital Roots(字符串)
Digital Roots Problem Description The digital root of a positive integer is found by summing the dig ...
- HDU 1013.Digital Roots【模拟或数论】【8月16】
Digital Roots Problem Description The digital root of a positive integer is found by summing the dig ...
- HDU 1013 Digital Roots(字符串,大数,九余数定理)
Digital Roots Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Tot ...
- HDU 1013 Digital Roots 题解
Problem Description The digital root of a positive integer is found by summing the digits of the int ...
- hdu 1013 Digital Roots
#include <stdio.h> int main(void) { int m,i;char n[10000]; while(scanf("%s",&n)= ...
- Problem : 1013 ( Digital Roots )
tips:分析不够仔细,白费了许多功夫.输入数据的范围,平时几乎很少考虑的,这个以后得注意.代码检查不够仔细啊,以后得注意了 #include<iostream> using namesp ...
- 解题报告:hdu1013 Digital Roots
2017-09-07 22:02:01 writer:pprp 简单的水题,但是需要对最初的部分进行处理,防止溢出 /* @theme: hdu 1013 Digital roots @writer: ...
随机推荐
- 【剑指Offer】25、复杂链表的复制
题目描述: 输入一个复杂链表(每个节点中有节点值,以及两个指针,一个指向下一个节点,另一个特殊指针指向任意一个节点),返回结果为复制后复杂链表的head.(注意,输出结果中请不要返回参数中的节 ...
- 【剑指Offer】1、二维数组中的查找
题目描述: 在一个二维数组中(每个一维数组的长度相同),每一行都按照从左到右递增的顺序排序,每一列都按照从上到下递增的顺序排序.请完成一个函数,输入这样的一个二维数组和一个整数,判断数组中是否 ...
- [置顶]
我的 Java 后端书架 (2016 年暖冬版)
转自: http://calvin1978.blogcn.com/articles/bookshelf16.html 我的 Java 后端书架 (2016 年暖冬版) 本书架主要针对 Java 后端 ...
- vue部署到nginx服务下,非根目录,刷新页面404怎么解决?
nginx配置 location / { proxy_pass http://xxxx; } location /category { root /home/tv; index index.html; ...
- Linux 系统查看命令
1. linux CPU大小cat /proc/cpuinfo |grep "model name" && cat /proc/cpuinfo |grep &quo ...
- 一种脱离VC编程软件的方法学习C/C++编程(搭建EditPlus实现在文本编辑框中执行.c文件
网上下载一个EditPlus记事本安装好后就可以按照下面步骤进行搭建环境了: 一.工具(Tools)→配置用户工具(Configure UserTools...),[添加工具](Add Tool> ...
- 善用性能工具进行SQL整体优化
SQL优化是一个复杂的工程,首先要讲究从整体到局部.今天我们首先学习关于数据库整体优化都有哪些性能工具,接着分析这些工具的特点,并结合案例进行探索,最后再进行总结和思考. 总体学习思路如下图所示: 都 ...
- Official Documents
1. Docker Installation https://docs.docker.com/install/linux/docker-ee/suse/ 2. Docker hub https://d ...
- GitHub分支项目不支持搜索问题解决:Sorry, forked repositories are not currently searchable.
错误如下: 在GitHub上的项目,如果是分支项目的星星数没有超过父项目,就不会去索引从而不会进行代码搜索. 解决方法: 1.要在搜索结果中包含分支,需要添加fork:true或fork:only查询 ...
- [Python] Use Static Typing in Python 3.6
In this lesson, you will learn how to statically type variables in Python 3.6 Static typing can help ...