-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathBai43.cpp
71 lines (58 loc) · 1.11 KB
/
Bai43.cpp
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
/*
Kiểu dữ liệu do người dùng tự định nghĩa: struct
*/
#include <iostream>
using namespace std;
struct Car {
char owner[100];
char brand[100];
char color[100];
int weight;
int height;
int width;
};
struct Cat {
char name[100];
int age;
float weight;
char color[100];
char eyesColor[100];
};
struct Student {
char ID[20];
char name[100];
int age;
float mark;
char address[100];
Car car;
Cat pet;
};
void getInfo(Student& s) {
cout << "Enter name: ";
cin.getline(s.name, 99);
cout << "Enter age: ";
cin >> s.age;
cout << "Enter address: ";
cin.ignore();
cin.getline(s.address, 99);
cout << "Enter mark: ";
cin >> s.mark;
cin.ignore();
cout << "Car color: ";
cin >> s.car.color;
}
void showInfo(Student s) {
cout << "========== Student Info ==========\n";
cout << "Name: " << s.name << endl;
cout << "Address: " << s.address << endl;
cout << "Age: " << s.age << endl;
cout << "Mark: " << s.mark << endl;
cout << "Car color: " << s.car.color << endl;
cout << "==================================\n";
}
int main() {
Student s;
getInfo(s);
showInfo(s);
return 0;
}