Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void zad9() {
- int a[17];
- double s_neg=0;
- int n_neg=0,s_pos=0;
- for(int i=0;i<18;i++) {
- a[i] = -50 + rand() % 100;
- cout << a[i] << " ";
- if (a[i]<0) {
- s_neg+=abs(a[i]);
- n_neg++;
- }
- }
- cout << endl;
- if (n_neg==0) {
- cout<<"Отрицательных чисел нет"<<endl;
- return;
- }
- s_neg/=n_neg;
- for(int i=0;i<18;i++)
- if (abs(a[i])>s_neg) {
- s_pos+=a[i];
- }
- cout<<"Sum: "<<s_pos<<'\n';
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement