私は平均スコアとして私にtest1/5を与え続けます。何が間違っているのかわかりません。 Iveは()を別の方法でグループ化しようとしました。私はそれがちょうど終了した一握りの時間を働いたことを誓う。今はほぼ1amと私はまだこの単純なコードを把握しようとしています。なぜ簡単な数学が使えないのですか?
たとえば:60、50、80、70、80は私の12の平均を与える(TEST1/5)
#include <iostream>
#include <string>
using namespace std;
double testAvgCal(double, double, double, double, double, double&);
void printing(double);
int main()
{
double test1 = 0;
double test2 = 0;
double test3 = 0;
double test4 = 0;
double test5 = 0;
double testAvg = 0;
cout << "Enter five test scores separated by commas: " << endl;
cin >> test1 >> test2 >> test3 >> test4 >> test5;
testAvgCal(test1, test2, test3, test4, test5, testAvg);
printing(testAvg);
}
double testAvgCal(double test1, double test2, double test3, double test4, double test5, double& testAvg)
{
testAvg = (test1 + test2 + test3 + test4 + test5)/ 5;
return testAvg;
}
void printing(double testAvg)
{
cout << "The test score average of this student is: " << testAvg << endl;
}
間違っている正確にどのような?結果は間違っていますか?もしそうなら、[here](http://stackoverflow.com/q/588004/5647260)を参照してください。 – Li357
「0。###」と表示されますか? –
Iveは10の倍数で試してみましたが、いつかは必要になると思います。 –