文章

1

粉丝

67

获赞

0

访问

8.3k

头像
在codeblocks里面成功运行,为什么在N诺runtime error?
P1153 北京大学机试题
发布于2021年5月11日 09:14
阅读数 8.3k

#include <iostream>
#include <cstdio>
const int maxn = 1e9+10;
char ch[maxn];

using namespace std;

int solve(int n){
    int tmp = n;
    int res = 0;
    while(tmp!=0)
    {
        res += tmp%10;
        tmp /= 10;
    }
    return res;
}

int main()
{
    string s;
    while(cin>>s&&s!='0')
    {
        long long n = 0;
        for(int i = 0; i < s[i]; i++)
        {
            n += s[i]-'0';
        }
        while(solve(n)>=10)
        {
           &n...

登录查看完整内容


登录后发布评论

2 条评论
admin SVIP
2021年5月11日 10:13

数组开太大了

赞(1)

jimapple : 回复 admin: 谢谢!!

2021年5月13日 13:28