题解
2025-08-28 20:20:22
发布于:上海
0阅读
0回复
0点赞
#include <iostream>
using namespace std;
int main() {
int n;
if (!(cin >> n)) return 0; // 读入整数
if (n == 0) { // 题目保证 n>0,可去掉
cout << 0;
return 0;
}
int res[10], len = 0; // 用数组保存余数
while (n) {
res[len++] = n % 7;
n /= 7;
}
for (int i = len - 1; i >= 0; --i) // 倒序输出
cout << res[i];
return 0;
}
这里空空如也
有帮助,赞一个