-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfancy-numbers.cpp
More file actions
42 lines (39 loc) · 812 Bytes
/
Copy pathfancy-numbers.cpp
File metadata and controls
42 lines (39 loc) · 812 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
#include <bits/stdc++.h>
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
using namespace std;
int main()
{
char num[20] = {'0'};
char aux_num[20] = {'0'};
cin >> num;
bool res = true;
int length = strlen(num);
for (int i = length - 1, j=0; i >= 0; i--, j++)
{
if(num[j] == '2' || num[j] == '3' || num[j] == '4' || num[j] == '5' || num[j] == '7')
{
res = false;
break;
}
else if(num[j] == '6')
aux_num[i] = '9';
else if(num[j] == '9')
aux_num[i] = '6';
else
aux_num[i] = num[j];
}
if (res)
{
// strcmp returns 0 if the strings have the same content
if(strcmp(num, aux_num) == 0)
printf("Sim\n");
else
printf("Nao\n");
} else {
printf("Nao\n");
}
return 0;
}