内部赛题目 求一个数能否被3整除 求每一位数的和时 要减去字符0

来源:互联网 发布:java数组最大长度限制 编辑:程序博客网 时间:2024/03/29 02:06

       由于数据的范围很大,普通的int,long等数据存不下来,故用字符数组存储,求各位数字之和。

 

#include <bits/stdc++.h>

 

usingnamespacestd;

 

constintmaxn = 1000;

 

charstr[maxn];

 

intmain()

{

    //freopen("in.txt","r",stdin);

    //freopen("out.txt","w",stdout);

 

    while(scanf("%s",str)!=EOF) {

        intans = 0;

        for(inti=0;i<strlen(str);i++)

            ans = ans + str[i] - '0';

 

        if(ans%3==0)

            puts("Yes");

        else puts("No");

    }

    return0;

}

 

 

0 0
原创粉丝点击