1234567891011121314151617181920212223242526272829303132333435363738394041
#include <iostream> #include <string> #include "Student.h" using namespace std; int main(){ int numOfStudents; cout << " Please enter the number of students " << ":"; cin >> numOfStudents; Student *s = new Student[numOfStudents]; cout << "Please enter student data" << ":" << endl; string studentName; int studentGrade = 0; for (int i = 0; i < numOfStudents; i++){ cout << "Name " << ": "; cin >> studentName; cout << "Grade " << ":"; cin >> studentGrade; s[i].setName(studentName); s[i].setGrade(studentGrade); cout << s[i].getName() << endl; cout << s[i].getGrade() << endl; } int size = 0; int sub=0; float avg = 0; for (int i = 0; i < size; i++){ sub += s[i].getGrade(); avg = sub / (float)(size); } cout << avg << endl; system("pause"); return 0; }
12345
for (int i = 0; i < size; i++){ sub += s[i].getGrade(); avg = sub / (float)(size); }
avg = sub / (float)(size);
1234567
int size = 0; int sub=0; float avg = 0; for (int i = 0; i < size; i++){ sub += s[i].getGrade(); } avg = sub / (float)(size); cout << avg << endl;
123456789
#include <iostream> int main() { int size = 0; for ( int i = 0; i < size; ++i ) { std::cout << "Hello\n"; } return 0; }
123
int size = 0; for (int i = 0; i < size; i++)