Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- int main() {
- int a[100], n;
- cout << "Nhap n: "; cin >> n;
- for (int i = 0; i < n; i++) {
- cout << "Nhap a[" << i << "]: ";
- cin >> a[i];
- }
- // task_a
- int am = 0, duong = 0;
- for (int i = 0; i < n; i++) {
- if (a[i] < 0) am++;
- if (a[i] > 0) duong++;
- }
- cout << "So so am: " << am << endl;
- cout << "So so duong: " << duong << endl;
- // task_b
- int chan = 0, le = 0;
- for (int i = 0; i < n; i++) {
- if (a[i] % 2 == 0) chan += a[i];
- else le += a[i];
- }
- cout << "Tong so chan: " << chan << endl;
- cout << "Tong so le: " << le << endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment