-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathqueue.cpp
More file actions
87 lines (70 loc) · 1.46 KB
/
queue.cpp
File metadata and controls
87 lines (70 loc) · 1.46 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
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
#include<iostream>
#include<string.h>
using namespace std;
class student
{
private:
string rollno[3];
int total;
string name[3];
float avg[3];
public :
void getdata(){
int M1,M2,M3;
cout << "Enter student 1 name " << endl;
cin >> name[0];
cout << "Enter rollno. " << endl;
cin >> rollno[0];
cin >> M1;
cin >> M2;
cin >> M3;
avg[0] = (M1+M2+M3)/3;
cout << "Enter student 2 name " << endl;
cin >> name[0];
cout << "Enter rollno. " << endl;
cin >> rollno[1];
cin >> M1;
cin >> M2;
cin >> M3;
avg[1] = (M1+M2+M3)/3;
cout << "Enter student 3 name " << endl;
cin >> name[0];
cout << "Enter rollno. " << endl;
cin >> rollno[2];
cin >> M1;
cin >> M2;
cin >> M3;
avg[2] = (M1+M2+M3)/3;
int i,j;
for(i=0;i<3;i++){
for(j=i;j<3;j++){
if(avg[i] < avg[j]){
int temp;
temp = avg[i];
avg[i] = avg[j];
avg[j] = temp;
string b;
b = name[i];
name[i] = name[j];
name[j] = b;
string c;
c = rollno[i];
rollno[i] = rollno[j];
rollno[j] = c;
}
}
}
}
void displaydata(){
int i;
for(i=0;i<3;i++){
cout << "Rank " << i+1 << "name " << name[i] << "rollno. " << rollno[i] << "average " << avg[i] << endl;
}
}
};
int main(){
student st;
st.getdata();
st.displaydata();
return 0;
}