-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathTask 1: Students database.cpp
98 lines (79 loc) · 1.8 KB
/
Task 1: Students database.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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
/** The Code For this Task Goes Here, Please add some documentations and Comments to make the reading easier **/
#include <iostream>
#include <algorithm>
using namespace std;
const int MAX_NAME=14; // Assume a name contains at most 14 characters
enum Gender{ MALE = 'm', FEMALE = 'f'};
string first_name; //global vars
string last_name;
double GPA;
int ID, n, temp = 0;
struct Date{
int year;
int month;
int day;
};
struct Student // Info
{
int ID;
string first_name;
string last_name;
Date birth_date;
Gender gender;
double GPA;
};
Student* s;
void InputStudent(Student *s){
cin>>s->ID;
cin>>s->first_name;
cin>>s->last_name;
cin>>s->birth_date.year;
cin>>s->birth_date.month;
cin>>s->birth_date.day;
//cin>>info.gender;
cin>>s->GPA;
}
void OutputStudent(Student *s){
cout<<s->ID<<endl;
cout<<s->first_name<<endl;
cout<<s->last_name<<endl;
cout<<s->birth_date.year<<endl;
cout<<s->birth_date.month<<endl;
cout<<s->birth_date.day<<endl;
cout<<s->GPA<<endl;
}
void InputAllStudent(Student *s ,int n){
bool LessThan(s);
bool GPAGreater(s);
}
void OutputAllStudent(Student *s ,int n){
for(int i = 0 ; i < n ; i++){
OutputStudent(s);
}
}
bool LessThan(Student *s){
for(int i = 0 ; i < n ; i++){
InputStudent(s);
if(temp < s->ID){
return 1;
} else return 0;
s->ID = temp;
}
}
bool GPAGreater (Student *s){
for(int i = 0 ; i < n ; i++){
InputStudent(s);
if(temp > s->GPA){
return 1;
} else return 0;
}
}
void SortStudents(Student* s, int n, bool (*LessThan)(Student*,Student*)){
}
int main()
{
Student* s;
InputAllStudent(s, n);
OutputAllStudent(s, n);
return 0;
}