123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
#include<iostream> #include<ios> #include<algorithm> #include<vector> #include<string> #include<iomanip> using namespace std; int main(){ cout << "Enter the first student's name: "; string name1; cin >> name1; cout << "Enter the second studesnt's name: "; string name2; cin >> name2; cout << "Enter the 10 homework grade for the first student: "; vector<double> stu1; vector<double> stu2; double x; double y; double sum1 = 0; double sum2 = 0; while(cin >> x && y != 10){ stu1.push_back(x); y++; sum1 += x; } cout << "Enter the homeworks grades for the second student: "; y = 0; while(cin >> x && y != 10){ stu2.push_back(x); y++; sum2 += x; } streamsize prec = cout.precision(); setprecision(3); cout << name1 << "'s average is: " << sum1 / 10 << endl; cout << name2 << "'s average is: " << sum2 / 10 << endl; setprecision(prec); return 0; }
y
double
y != 10
int
double y;
int y = 0;