Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include<cmath>
- using namespace std;
- const int n = 2;
- main()
- {
- int a[n] = {},b[n] = {};
- double S = 0, Sb = 0;
- for(int i = 0; i<n; i++)
- {
- cin >> a[i] >> b[i];
- if (a[i]>0)
- {
- S=S + a[i];
- }
- if(b[i]<0)
- {
- Sb=Sb+fabs(b[i]);
- }
- }
- if(S>Sb)
- {
- int c[n]={};
- for(int i=0; i<n; i++)
- {
- c[i]=a[i]+b[i];
- cout << c[i] << endl;
- }
- }
- else
- {
- for(int i=0; i<n; i++)
- {
- if(b[i]<0)
- {
- b[i]=0;
- }
- }
- }
- for(int i=0; i<n; i++)
- {
- cout << a[i] <<endl;
- }
- for(int i=0; i<n; i++)
- {
- cout << b[i] <<endl;
- }
- system("pause");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement