新手在国外刚开始学习 上课听不懂 下面要求一组平均速度保留一位小数 死活算不对
程序代码:
#include <iostream> #include <stdlib.h> #include <iomanip> using namespace std; int main() { int ss; //SchimmenSekunden int rs; //RadfahrenSkunden int ls; //LaufenSekunden cout << "Zeit Schwimmen (s) : "; cin >> ss; cout << "Zeit Radfahren (s) : "; cin >> rs; cout << "Zeit Laufen (s) : "; cin >> ls; cout << endl; int zs = ss / 60; //ZeitSchwimmen int zr = rs / 60; //ZeitRadfahren int zl = ls / 60; //ZeitLaufen int rw = ss % 60; //restMinSchwimmen int rr = rs % 60; //restMinRadfahren int rl = ls % 60; //restMinLaufen double gs = 3.86 / (ss / 3600); //Geschw.schwimmen double gr = 180 / (rs / 3600); //Geschw.radfahren double gl = 42.2 / (ls / 3600); //Geschw.laufen cout << "Zeit Schwimmen : " << zs << " Min " << rw << " Sek, " << " Gschw. " << setprecision(3) << gs << " km/h " << endl; cout << "Zeit Radfahren : " << zr << " Min " << rr << " Sek, " << " Gschw. " << setprecision(3) << gr << " km/h " << endl; cout << "Zeit Laufen : " << zl << " Min " << rl << " Sek, " << " Gschw. " << setprecision(3) << gl << " km/h " << endl; cout << endl; double dg = 226.06 / ((ss + rs + ls) / 3600); cout << "Durchschnittsgeschwindigkeit : " << setprecision(3) << dg << endl; system("pause"); return 0;