วันพุธที่ 9 พฤศจิกายน พ.ศ. 2559
C++ หาคะแนนรวมของนักเรียน 100 คน
struct student
{
int homework1;
int homework2;
int homework3;
int homework4;
int homework5;
int mid;
int _final;
int sum;
};
int main()
{
system("cls");
srand(time(NULL));
student s[101];
for (int i = 1; i <= 100; i++)
{
s[i].homework1 = rand() % 4;
s[i].homework2 = rand() % 4;
s[i].homework3 = rand() % 4;
s[i].homework4 = rand() % 4;
s[i].homework5 = rand() % 4;
s[i].mid = rand() % 30;
s[i]._final = rand() % 50;
s[i].sum = s[i].homework1 + s[i].homework2+ s[i].homework3+ s[i].homework4+ s[i].homework5+ s[i].mid + s[i]._final;
}
for (int i = 1; i <= 100; i++)
{
cout << "Student#" << i << " Score Homework#1 = " << s[i].homework1 << endl;
cout << "Student#" << i << " Score Homework#2 = " << s[i].homework2 << endl;
cout << "Student#" << i << " Score Homework#3 = " << s[i].homework3 << endl;
cout << "Student#" << i << " Score Homework#4 = " << s[i].homework4 << endl;
cout << "Student#" << i << " Score Homework#5 = " << s[i].homework5 << endl;
cout << "Student#" << i << " Score mid = " << s[i].mid << endl;
cout << "Student#" << i << " Score final = " << s[i]._final << endl;
cout << "Student#" << i << " Sum Score = " << s[i].sum << endl;
cout << endl;
}
return 0;
}
สมัครสมาชิก:
ส่งความคิดเห็น (Atom)
yeah
ตอบลบ