1013


Problem Description
The digital root of a positive integer is found by summing the digits of the integer. If the resulting value is a single digit then that digit is the digital root. If the resulting value contains two or more digits, those digits are summed and the process is repeated. This is continued as long as necessary to obtain a single digit.

For example, consider the positive integer 24. Adding the 2 and the 4 yields a value of 6. Since 6 is a single digit, 6 is the digital root of 24. Now consider the positive integer 39. Adding the 3 and the 9 yields 12. Since 12 is not a single digit, the process must be repeated. Adding the 1 and the 2 yeilds 3, a single digit and also the digital root of 39.
 

Input
The input file will contain a list of positive integers, one per line. The end of the input will be indicated by an integer value of zero.
 

Output
For each integer in the input, output its digital root on a separate line of the output.
 

Sample Input
  
  
24 39 0
 

Sample Output
  
  
6 3
#include <iostream>
#include <cstring>
using namespace std;
int main()
{
    char n[1000];
    while(cin>>n)
    {
        if(strcmp(n,"0")==0)
            break;
        int counts=strlen(n);
        int sum=0,root=0;
        for(int i=0; i<counts; i++)
            sum+=(n[i]-'0');
        if(sum>=10)
            root=sum%9;
        else
            root=sum;
        if(root==0)
            cout<<"9"<<endl;
        else
            cout<<root<<endl;
    }
    return 0;
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
简介: USB转com驱动由官方Prolific USB-to-Serial 提供,Prolific USB-to-Serial Comm Port在连个文件一个win7系统专用,一个xp系统专用(文件名已说明)。 还有一个USB转串口。 使用注意: 如若win10之前对pl2303支持较好,可是使用,那就不必要进行一下操作了,否则,你需要先卸载之前相关的一切pl2303驱动,安装本驱动(pl2303),并进行如下设置,以保证重启后驱动正常:此电脑右键->属性->高级系统设置->硬件->安装设备设置,选择“否,让我选择要执行的操作”“从不安装来自Windows更新的驱动程序软件” 使用方法: 第一步:解压文件,先安装Prolific USB-to-Serial Comm Port。安装成功后,到“设备管理器”->右键“扫描检测硬件更改”查看。如果没有符号提示。说明驱动正常安装,点击可以看对应的COM口为com几。如有“黄色!”,查看提示“该设备无法正常启动 (代码10)”则执行第二步: 安装Y340 USB转串口驱动,里面有两个文件,先试HL-340,安装后插入usb-toserial线,自动安装应该可以正常运行,如果不行,再试另一个文件,同样的安装方法。。。行不行?多试几次就可以应该可以。。。。。 ================================================================================================ 本资料共包含以下附件: windows 7_ _32_64 USB-to-Serial Comm Port.zip YH-340 USB转串口驱动.zip win_me_2000_XP USB-to-Serial.zip

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值