Diene

Untitled

Mar 20th, 2018
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.45 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. int main(){
  6.  
  7. double x, soma=0, contador=0, ok=1;
  8. double media;
  9. int casa;
  10. char c;
  11.  
  12. while(1){
  13.     scanf("%lf", &x);
  14.     soma=soma+x;
  15.     contador++;
  16.     scanf("%c", &c);
  17.     if(c=='\n') break;
  18. }
  19. media=soma/contador;
  20. casa=soma/contador;
  21. if(media-(int)media>=0.5){
  22.     casa=(soma/contador)+1;
  23.     printf("%d", casa);
  24. }
  25. else if(media-(int)media<0.5){
  26.     printf("%d", casa);
  27. }
  28.  
  29. return 0;
  30. }
Add Comment
Please, Sign In to add comment