fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5. float media;
  6. string macchina;
  7. float km;
  8. float litri;
  9. int conta=0;
  10. int totalekm=0;
  11. int totalelitri=0;
  12. do {
  13. cin>> macchina;
  14. cin>>km;
  15. cin>>litri;
  16. if (km!=0){
  17. totalekm= totalekm + km;
  18. totalelitri= totalelitri + litri;
  19. conta= conta + 1;
  20.  
  21. }
  22. } while (km!=0);
  23. media= 1.0* totalekm/ totalelitri;
  24. cout<< media;
  25.  
  26. // your code goes here
  27. return 0;
  28. }
Success #stdin #stdout 0.01s 5264KB
stdin
mercedes
300
50
audi
20
2
bmw
80
15
n
0
0
stdout
5.97015