编号 题目 状态 分数 总时间 内存 代码 / 答案文件 提交者 提交时间
#6522 #1082. 速算大师小 R Compile Error 0 0 ms 0 K C++ 17 / 611 B Pia 2024-11-16 15:51:39
显示原始代码
#include <bits/stdc++.h>
using namespace std;
int countDigits(long int);
int main() {
    long long int p, n = 1, sum = 0;
    long int m;
    cin >> p;
    for (int i = 0; i < p; i++) {
        for (int j = 0; j < i; j++) {
            n *= 2;
        }
        sum += n;
        n = 1;
    }
    m = countDigits(sum);
    cout << m << endl;
    long long int a[m];
    for (int i = 0; i < n; i++) {
        a[i] = sum % 10;
        sum /= 10;
    }
    for (int h = 10; h >= 1; h--) {
        for (int i = 50 * h; i > 50 * (h - 1); i--) {
            cout << a[i];
        }
        cout << endl;
    }
    return 0;
}

int countDigits(long long int sum) {
    long long int count = 0;
    while (sum != 0) {
        sum /= 10;
        count++;
    }
    return count;
}

编译信息

/usr/bin/ld: /tmp/ccXbCBDg.o: in function `main':
a.cpp:(.text.startup+0x83): undefined reference to `countDigits(long)'
collect2: error: ld returned 1 exit status