Advertisement
Guest User

Untitled

a guest
Nov 12th, 2019
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.92 KB | None | 0 0
  1. #include <iostream>
  2. #include <cmath>
  3. #include "pch.h"
  4. using namespace std;
  5. int main() {
  6. setlocale(LC_ALL, "Russian");
  7. int n;
  8. cin >> n;
  9. double sum=0,sumpoloj=0,c=0,min=n,max=n,pred=0,predpred=0;
  10. if (n!=0)
  11. while (n != 0)
  12. {
  13. predpred=pred; pred=n;
  14. cin>>n;
  15. if(n!=0)
  16. {
  17. if ((n>0)) {
  18. sumpoloj=sumpoloj+n;
  19. c++;
  20. }
  21.  
  22. int pervoechislo=0;
  23. if ((pred<0&&n<0)) { sum=sum+n;
  24. 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