-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathupside_down.cpp
60 lines (48 loc) · 907 Bytes
/
upside_down.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
53
54
55
56
57
58
59
60
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main() {
int t;
cin >> t;
for ( int k = 0; k < t; k++ ) {
string arr;
cin >> arr;
vector<char> brr;
int s = arr.size();
bool flag = true;
for(int i = 0; i < s; i++ ) {
if ( arr[i] == '2' || arr[i] == '3' || arr[i] == '4' || arr[i] == '5' || arr[i] == '7' ) {
cout << "NO" << endl;
flag = false;
break;
} else {
switch (arr[i] ) {
case '9' :
brr.push_back('6');
break;
case '6' :
brr.push_back('9');
break;
case '1' :
brr.push_back('1');
break;
case '0' :
brr.push_back('0');
break;
case '8':
brr.push_back('8');
break;
}
}
}
if ( flag ) {
cout << "YES" << endl;
for ( int i = brr.size() - 1; i >= 0; i-- ) {
cout << brr[i];
}
cout << endl;
}
}
return 0;
}