3 条题解
-
2
这是基础的数位拆分,当然也能用字符串
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; int a[10], cnt = 0; while (n) { a[++cnt] = n % 10; n /= 10; } cout << cnt << endl; for (int i = cnt; i >= 1; i--) cout << a[i] << " "; cout << endl; for (int i = 1; i <= cnt; i++) cout << a[i]; cout << endl; return 0; }
-
1
#include<bits/stdc++.h> using namespace std; int main() { int n, s = 0, c = 0; cin >> n; //求n倒过来的数,求n的位数; while(n != 0){ s = s*10 + n%10; n /= 10; c++; } cout << c << endl; //求s倒过来的数 int t = s; while(t != 0){ cout << t%10 << " "; t /= 10; } cout << endl; cout << s << endl; return 0; }
- 1
信息
- ID
- 959
- 时间
- 1000ms
- 内存
- 16MiB
- 难度
- 2
- 标签
- 递交数
- 69
- 已通过
- 45
- 上传者