-
Notifications
You must be signed in to change notification settings - Fork 148
Expand file tree
/
Copy pathreverse_the_number.cpp
More file actions
44 lines (40 loc) · 864 Bytes
/
Copy pathreverse_the_number.cpp
File metadata and controls
44 lines (40 loc) · 864 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
// https://www.codechef.com/problems/FLOW007// SOLUTION NOT READY
#include <iostream>
#include<vector>
using namespace std;
void reverse_string()
{
string number;
cin >> number;
int start_point = number.size()-1;
// If the last numebr is 0
if(number[number.size()-1] =='0')
{
for(int i = number.size()-1; i>=0; i--)
{
if(number[i] != number[i-1])
{
start_point = i-1;
break;
}
}
}
for(int i=start_point; i>=0; i--)
{
cout<<number[i];
}
cout<<""<<endl;
}
int main()
{
// number of test cases
int t;
string number;
// Read number of test cases
cin >>t;
for(int i =0; i<t; i++)
{
reverse_string();
}
return 0;
}