SHARE
TWEET

Untitled

a guest Oct 10th, 2019 82 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include<stdio.h>
  2. #include<cmath>
  3.  
  4. int main() {
  5.     int n, f, sump = 0, sumo = 0, countp = 0, counto = 0;
  6.     float srp=0, sro=0;
  7.     scanf_s("%d", &n);
  8.     for( int i = 1 ; i <= n; i++) {
  9.         scanf_s("%d", &f);
  10.         if (f > 0) {
  11.             sump += f;
  12.             countp += 1;
  13.         }
  14.         else {
  15.             sumo += f;
  16.             counto += 1;
  17.         }
  18.     }
  19.     srp = sump / countp;
  20.     sro = sumo / counto;
  21.  
  22.     printf("%d %d %d %d", sumo, counto, sump, countp);
  23.  
  24.     if (srp > abs(sro)) {
  25.         printf("%f", srp);
  26.     }
  27.     else {
  28.         printf("%f", sro);
  29.     }
  30.     system("pause");
  31.     return 0;
  32. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top