C++
- @Linda_pp
- 清楚なC++メイドBOT
- 長谷川一輝
- @jj1bdx
- 安藤敏彦
- Siv3D
- @hnokx
- @ishidakei
- TAKEI Yuya
- I (@wx257osn2)
- Tommy6
- @nekketsuuu
- LouiS0616
- @volanja
- 大鎌広
- むてら
- ガチKGB
- 三重野賢人
x
59
1
2
3
using namespace std;4
5
int studentNumber=0;6
int testNumber=0;7
struct Student8
{9
string name,grade;10
int studentNo,*testResults;11
double average;12
};13
14
Student* Students;15
16
void getValue()17
{18
cout << "Enter the number of students: ";19
cin >> studentNumber;20
cout << "Enter the number of tests: ";21
cin >> testNumber;22
23
Students = new Student[studentNumber];24
25
for(int i=0; i< studentNumber; i++)26
{27
cout<< "\n" << "Enter the name of the " << i+1 << ". student: ";28
cin >> Students[i].name;29
cout<< "\n" << "Enter the number of the " << i+1 << ". student: ";30
cin >> Students[i].studentNo;31
32
Students[i].testResults = new int[testNumber];33
34
for(int z=0; z<testNumber; z++)35
{36
cout<< "\n" << "Enter the " << z+1 << ". exam grade of the " << i+1 << ". student: " ;37
cin >> Students[i].testResults[z];38
}39
}40
}41
42
void show()43
{44
for(int i=0; i < studentNumber; i++)45
{46
cout<< "\n" << Students[i].name;47
cout<< "\n" << Students[i].studentNo;48
for(int z=0; z<testNumber; z++)49
{50
cout<< "\n" <<Students[i].testResults[z];51
}52
}53
}54
55
int main()56
{57
getValue();58
show();59
}$ g++ prog.cc -Wall -Wextra -std=c++11 -pedantic
Stdin
5 5hoge 100 1 2 3 4 5fuga 200 6 7 8 9 10a 300 100 100 100 100 100erererere 400 0 0 0 0 0zzzzz 500 1000000 1000000 1000000 1000000 1000000Start
Enter the number of students: Enter the number of tests: Enter the name of the 1. student: Enter the number of the 1. student: Enter the 1. exam grade of the 1. student: Enter the 2. exam grade of the 1. student: Enter the 3. exam grade of the 1. student: Enter the 4. exam grade of the 1. student: Enter the 5. exam grade of the 1. student: Enter the name of the 2. student: Enter the number of the 2. student: Enter the 1. exam grade of the 2. student: Enter the 2. exam grade of the 2. student: Enter the 3. exam grade of the 2. student: Enter the 4. exam grade of the 2. student: Enter the 5. exam grade of the 2. student: Enter the name of the 3. student: Enter the number of the 3. student: Enter the 1. exam grade of the 3. student: Enter the 2. exam grade of the 3. student: Enter the 3. exam grade of the 3. student: Enter the 4. exam grade of the 3. student: Enter the 5. exam grade of the 3. student: Enter the name of the 4. student: Enter the number of the 4. student: Enter the 1. exam grade of the 4. student: Enter the 2. exam grade of the 4. student: Enter the 3. exam grade of the 4. student: Enter the 4. exam grade of the 4. student: Enter the 5. exam grade of the 4. student: Enter the name of the 5. student: Enter the number of the 5. student: Enter the 1. exam grade of the 5. student: Enter the 2. exam grade of the 5. student: Enter the 3. exam grade of the 5. student: Enter the 4. exam grade of the 5. student: Enter the 5. exam grade of the 5. student: hoge 100 1 2 3 4 5 fuga 200 6 7 8 9 10 a 300 100 100 100 100 100 erererere 400 0 0 0 0 0 zzzzz 500 1000000 1000000 1000000 1000000 1000000
0
Finish