-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinti.cpp
40 lines (36 loc) · 930 Bytes
/
inti.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
#include <iostream>
#include <string>
#include "math.h"
#include <vector>
#include <string>
using namespace std;
// Function to print all sub strings
int reverse(int x) {
int temp = x;
std::vector<int> res;
if(temp > 0) {
while(temp != 0) {
res.push_back(temp % 10);
temp = temp / 10;
}
for(int i=0; i<res.size(); ++i){
std::cout << res[i];
}
} else {
temp = abs(temp);
while(temp != 0) {
res.push_back(temp % 10);
temp = temp / 10;
}
for(int i=0; i<res.size(); ++i){
std::cout << res[i];
}
}
}
int main(int argc, const char * argv[]) {
int hex_str;
cin >> hex_str;
reverse(hex_str);
// cout << hex2dec(hex_str) << endl;
return 0;
}