Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- #define int long long
- signed main()
- {
- int n;
- cin >> n; // size of array a
- int a[n + 5]; // [0 , n + 4]
- for(int i = 0; i < n; i++){
- cin >> a[i]; // element in the i-th index (position)
- }
- int s = 0;
- int odd = 0 , even = 0;
- for(int i = 0; i < n; i++){
- s += a[i];
- if(a[i] % 2 == 0)
- even++;
- else
- odd++;
- }
- cout << "Sum of array: " << s << endl;
- cout << "Even: " << even << endl;
- cout << "Odd: " << odd << endl;
- /*
- for(int i = 0; i < n; i++){
- cout << a[i] << " ";
- }
- cout << endl; // [0 , n - 1]
- for(int i = n - 1; i >= 0; i--){
- cout << a[i] << " ";
- }*/
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement