Advertisement
Guest User

Untitled

a guest
Oct 10th, 2019
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.52 KB | None | 0 0
  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. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement