1 solutions
-
0
签到题,用两个数组分别存储一下即可
#include <bits/stdc++.h> using namespace std; int a[1010], b[1010], aa = 0, bb = 0, maxa = -1, maxb = -1; int main() { int n; cin >> n; while (n--) { int t; cin >> t; if (t % 2 == 1) a[aa++] = t; else b[bb++] = t; } cout << aa << endl; if (aa > 0) { cout << a[0]; for (int i = 1; i < aa; i++) cout << " " << a[i]; cout << endl; } cout << bb << endl; if (bb > 0) { cout << b[0]; for (int i = 1; i < bb; i++) cout << " " << b[i]; } return 0; }
Information
- ID
- 676
- Time
- 1000ms
- Memory
- 256MiB
- Difficulty
- 5
- Tags
- (None)
- # Submissions
- 62
- Accepted
- 24
- Uploaded By