-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGohar.cpp
More file actions
44 lines (40 loc) · 986 Bytes
/
Copy pathGohar.cpp
File metadata and controls
44 lines (40 loc) · 986 Bytes
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
#include <iostream>
#include <string>
using namespace std;
struct students{
string name;
string surname;
int mark;
friend std::ostream & operator << (std::ostream &, students *);
};
std::ostream & operator << (std::ostream & c, students * p){
for(int i = 0; i < 5; i++)
{
c << (*(p+i)).name <<" "<< (*(p+i)).surname <<" "<< (*(p+i)).mark<<'\n';
}
return c;
}
int main()
{
students st[5] = {
{"Edgar", "Xachatryan", 12},
{"Poxos", "Poxosyan", 45},
{"Gohar", "Xachatryan", 1},
{"Gohar", "Xachatryan", 78},
{"Gohar", "Xachatryan", 2}
};
students * s = st;
for(int i = 0; i < 4; i++)
{
for(int j = 0; j < 4-i; j++)
{
if((*(st + j)).mark > (*(st+j+1)).mark)
{
students temp = *(st+j);
*(st+j) = *(st+j+1);
*(st+j+1) = temp;
}
}
}
std::cout<<st;
}