Problem : 1013 ( Digital Roots )
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 )的更多相关文章
- 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 ...
- 杭电 1013 Digital Roots
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1013 反思:思路很简单,但是注意各位数加起来等于10的情况以及输入0的时候结束程序该怎么去表达 #in ...
- hdu 1013 Digital Roots
#include <stdio.h> int main(void) { int m,i;char n[10000]; while(scanf("%s",&n)= ...
- 解题报告:hdu1013 Digital Roots
2017-09-07 22:02:01 writer:pprp 简单的水题,但是需要对最初的部分进行处理,防止溢出 /* @theme: hdu 1013 Digital roots @writer: ...
随机推荐
- C语言_结构体的4种定义初始化方式及案例
结构体是一种构造数据类型 (构造数据类型:数组类型.结构体类型(struct).共用体类型(union)).用途:把不同类型的数据组合成一个整体,通俗讲就像是打包封装,把一些有共同特征(比如同属于某一 ...
- 在测试crontab执行脚本的时候,修改了linux的系统时间,crontab不执行了。
今天在写服务器的perl脚本的时候,在完成一版脚本打算通过crontab来测试一下呢,因为直接执行脚本文件是没有问题的,但是当配置到crontab定期执行时就会出现问题,到了指定的时间了,但是脚本文件 ...
- AttributeError: 'TestLogin' object has no attribute 'driver' in Pycharm for python selenium
自动化测试学习中的问题: 最近几天在写登陆测试,遇到一个问题,困惑我的几个小时......... 我各种百度,花费大量时间,才找到我的问题的根本所在,最终解决了我的问题,主要是大小写的问题def Se ...
- Trump就职演说
美东时间1月20日,特朗普在美国国会大厦宣誓就职,正式成为第45任美国总统.特朗普在就职演说中说,"我们曾经致力于保卫其他国家的领地,却忽略了我们自己的领土.我们曾经将成千上万亿美元转移到海 ...
- SystemVerilog语言简介(三)
15. 强制类型转换 Verilog不能将一个值强制转换成不同的数据类型.SystemVerilog通过使用'操作符提供了数据类型的强制转换功能.这种强制转换可以转换成任意类型,包括用户定义的类型.例 ...
- php和java中的加密和解密
遇到的java代码如下: Cipher cipher=Cipher.getInstance("DESede/CBC/PKCS5Padding"); 在php中使用des算法 始终校 ...
- Cookie操作类、压缩、序列化
1.cookie类 CartCookie.cs using System; using System.Data; using System.Configuration; using System.We ...
- python学习之字典(Dictionary)练习
Python字典是另一种可变容器模型,且可存储任意类型对象,如字符串.数字.元组等其他容器模型 字典中分为键值对 , key 类型需要时被哈希. value 类型可以是 字符串.数字.元组等其他容器模 ...
- Java web切面编程
在我们的 web开发中 我们在 对公用的 一些方法 我们需要抽取出来 这样达到 代码的冗余 今天 我利用项目上用的AOP的 实际 应用做了一个整理 首先 xml配置 扫描 <?xm ...
- VMware vSphere学习整理
知识点整理 内存选择 一般来说,每个虚拟机需要的内存在1~4GB甚至更多,还要为VMware ESXi预留一部分内存 2个6核的2U服务器配置64GB内存,4个6核或8核心的4U服务器配置128GB或 ...