-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSource.cpp
More file actions
96 lines (74 loc) · 1.53 KB
/
Source.cpp
File metadata and controls
96 lines (74 loc) · 1.53 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
88
89
90
91
92
93
94
95
96
#include <iostream>
#include<Windows.h>
using namespace std;
using std::cout;
using std::endl;
// Ìàòåìàòè÷íèé êàëüêóëÿòîð
// / \
// ×èñëà <- Îïåðàö³¿(îïåðàíäè)
// / \ / \
//Öèôðè (ñèìâîëè) Çíà÷åííÿ Ïîçíà÷åííÿ ×èñëà (îïåðàíäè)
class Operator
{
private:
char Symbole;
public:
Operator(){}
Operator(char val)
{
Symbole = val;
}
char Show()
{
return Symbole;
}
};
struct Number
{
char Symbol;
int Value;
};
// Âèðàç
class Statement
{
private:
Number number[2];
Operator operations[2];//+=
// ÿê³ äàí³ áóäóòü çáåð³ãàòèñü
public:
//Ìåòîäè
//Çàäàòè ÷èñëà
Statement(int x, int y)
{
//Ïåðøå ÷èñëî
number[0] = Number();
number[0].Value = x;
//Äðóãå ÷èñëî
number[1] = Number();
number[1].Value = y;
operations[0] = Operator('+');
operations[1] = Operator('=');
}
//Ïîáóäóâàòè ôîðìóëó
int Build()
{
int sum = number[0].Value + number[1].Value;
cout << "Ñôîðìîâàíèé âèðàç:" << endl;
cout << number[0].Value << operations[0].Show()
<< number[1].Value << operations[1].Show()
<< sum << endl;
return sum;
}
};
int main()
{
setlocale(LC_ALL, "ukr.utf8");
int x = 0, y = 0;
cout << "Ââåä³òü ÷èñëî õ:" << endl;
cin >> x;
cout << "Ââåä³òü ÷èñëî ó:" << endl;
cin >> y;
Statement statement = Statement(x, y);
statement.Build();
cin.get();
}