fork(1) download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5. float media;
  6. int totale=0;
  7. int conta=0;
  8. int tempo=0;
  9. do {
  10. cin >>tempo;
  11. if (tempo!= 0){
  12. totale= totale+ tempo;
  13. conta=conta+1;
  14. }
  15. } while (tempo!= 0);
  16. media= 1.0* totale/ conta;
  17. cout <<media;
  18.  
  19. // your code goes here
  20. return 0;
  21. }
Success #stdin #stdout 0s 5288KB
stdin
30
35
65
40
50
15
0
stdout
39.1667