Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cmath>
- #include "pch.h"
- using namespace std;
- int main() {
- setlocale(LC_ALL, "Russian");
- int n;
- cin >> n;
- double sum=0,sumpoloj=0,c=0,min=n,max=n,pred=0,predpred=0;
- if (n!=0)
- while (n != 0)
- {
- predpred=pred; pred=n;
- cin>>n;
- if(n!=0)
- {
- if ((n>0)) {
- sumpoloj=sumpoloj+n;
- c++;
- }
- int pervoechislo=0;
- if ((pred<0&&n<0)) { sum=sum+n;
- if (pervoechislo==0||(predpred>0&&pred<0)||(predpred<0&&pred>0)) { sum=sum+pred; } pervoechislo++; } if (min > n) min = n; if (max < n) max = n;} } if (c!=0) cout <<"Summa: "<< sum << endl << "Srednee: "<<sumpoloj / c<< endl <<"Max: "<<max<< endl <<"Min: "<<min<<endl; system("pause"); }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement