-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclass_1-23.cpp
52 lines (47 loc) · 932 Bytes
/
class_1-23.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
#include <iostream>
using namespace std;
struct X
{
int x;
string y;
char z;
};
//Sorting algorithm example for
int main()
{
X array[] = {
{3, "abc", 'x'},
{5, "abc", 'z'},
{3, "def", 'z'},
{3, "abc", 'x'},
{5, "bbb", 'y'},
{5, "def", 'y'},
};
sort(array, array + 6, [](X, &a, X &b))
{
if (a.n != b.n) return
if (a.s != b.s) return
return a.c < b.c;
}
}
//Infix notation: a + b (a+b)*c
//Postfix notation: a b + c *
//In postfix notation, a and b are added to a stack, then both read from it when the + is called. This value is readded to stack.
//Numbers are added to the stack; operators are done on them.
/* Postfix 2 3 + 4 *
->
-> 2
-> 2 3
-> 5
-> 5 4
-> 20
*/
//Infix: 3-2 = 1 // Postfix: 3 2 -
//Infix: -(7+3)
/* Postfix: 7 3 + ~
->
-> 7
-> 7 3
-> 10
-> -10
*/