- 分离整数的各个数
发
- @ 2025-12-20 9:09:41
#include using namespace std;
int main() { int n; cin >> n;
if (n == 0) {
cout << 0;
return 0;
}
bool first = true;
while (n > 0) {
int digit = n % 10;
if (first) {
cout << digit;
first = false;
} else {
cout << " " << digit;
}
n = n / 10;
}
return 0;
}
1 comments
-
Csvoner SU @ 2025-12-26 19:43:30
题解请直接发在右侧【题解】区,并尝试学习使用
markdown格式增加可读性。
- 1
Information
- ID
- 582
- Time
- 1000ms
- Memory
- 256MiB
- Difficulty
- 2
- Tags
- (None)
- # Submissions
- 269
- Accepted
- 171
- Uploaded By