Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <math.h>
- using namespace std;
- int main()
- {
- int n;
- cout << "n="; cin >> n;
- int *a = new int[n];
- int i, s1, s2;
- s1 = s2 = 0;
- for (i = 0; i < n; i++)
- {
- cout << "a[" << i << "]="; cin >> a[i];
- }
- for (i = 0; i < n / 2; i++)
- if (a[i]>0)
- s1 = s1 + a[i];
- for (i = n / 2; i < n; i++)
- if (a[i] < 0)
- s2 = s2 + a[i];
- cout << "s1=" << s1 << endl;
- cout << "s2=" << s2<<endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement