-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path7-quiz-array2D.cpp
More file actions
50 lines (41 loc) · 1.58 KB
/
7-quiz-array2D.cpp
File metadata and controls
50 lines (41 loc) · 1.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#include <iostream>
using namespace std;
/* Buatlah program sederhana untuk menampilkan data pemain persib
1. Tampilkan nama 5 Squad Tim Persib meliputi : No Punggung, Nama, Tempat Lahir, Posisi
2. Gunakan Array 2 Dimensi & Nested Loop
3. Tampilkan juga 1 baris data pemain yang no punggungnya : 98
*/
#include <iostream>
#include <iomanip>
using namespace std;
int main() {
cout << "Daftar Squad Tim PERSIB" << endl;
cout << "==================================================================" << endl;
string pemain[5][4] = {
{"14","Teja Paku Alam","Sumbar","Goal Keeper"},
{"6","Robi Darwis","Cianjur","Defender"},
{"33","Thom Haye","Belanda","Midfielder"},
{"7","Beckham Putra","Bandung","Midfielder"},
{"98","Ramon Tangue","Dago Bandung","Striker"}
};
// Header tabel dengan lebar kolom yang sama
cout << left << setw(15) << "No Punggung"
<< setw(20) << "Nama"
<< setw(20) << "Tempat Lahir"
<< setw(15) << "Posisi" << endl;
cout << "==================================================================" << endl;
for (int i = 0; i < 5; i++) {
cout << left << setw(15) << pemain[i][0]
<< setw(20) << pemain[i][1]
<< setw(20) << pemain[i][2]
<< setw(15) << pemain[i][3]
<< endl;
}
cout << "==================================================================" << endl;
for(int i=4; i<5; i++){
for (int j=0; j<4; j++){
cout<<" "<<pemain[i][j];
}
}
return 0;
}