-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsol.cpp
More file actions
executable file
·53 lines (45 loc) · 888 Bytes
/
Copy pathsol.cpp
File metadata and controls
executable file
·53 lines (45 loc) · 888 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
45
46
47
48
49
50
51
52
53
#include <bits/stdc++.h>
using namespace std;
vector<pair<char, char>> options = {
{'+', '='},
{'-', '='},
{'*', '='},
{'/', '='},
{'=', '+'},
{'=', '-'},
{'=', '*'},
{'=', '/'},
};
bool canSolve(char op1, char op2, int a, int b, int c)
{
if (op1 == '=')
{
swap(a, b);
swap(b, c);
swap(op1, op2);
}
if (b == 0 && op1 == '/')
return false;
if (op1 == '+')
return a + b == c;
if (op1 == '-')
return a - b == c;
if (op1 == '*')
return a * b == c;
if (op1 == '/')
return a / b == c;
}
int main()
{
int a, b, c;
cin >> a >> b >> c;
for (auto opt : options)
{
if (canSolve(opt.first, opt.second, a, b, c))
{
cout << a << opt.first << b << opt.second << c << endl;
break;
}
}
return 0;
}