Skip to content

Commit

Permalink
Update reverse_the_number.cpp
Browse files Browse the repository at this point in the history
  • Loading branch information
omonimus1 authored Oct 25, 2020
1 parent c44c157 commit 13dd7bc
Showing 1 changed file with 44 additions and 0 deletions.
44 changes: 44 additions & 0 deletions codechef/reverse_the_number.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,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;
}

0 comments on commit 13dd7bc

Please sign in to comment.