I was trying to scan numbers as string. Then to print the output ( reverse number ) I just reversed the string. But I got wrong answer for that solution. Can anyone explain to me what is the issue here?
My submission: CodeChef: Practical coding for everyone
problem: CodeChef: Practical coding for everyone
Your code doesn’t ignore leading zeroes.
1 Like
@evan_13 , you have to print leading zeroes of your string not the entire string.Hope this will help :)-
1 Like
u r getting error because u are not removing the zeros in front of the revesed number(if zeros end of thegiven number)so that way u atre getting error.
look at it once
#include <bits/stdc++.h>
using namespace std;
int main() {
int t,i,j;
string s;
cin>>t;
while(t–)
{
j=0;
cin>>s;
reverse(s.begin(),s.end());
for(i=0;i<s.length();i++)
{
if(s[i]==‘0’)
j++;
else
break;
}
for(j;j<s.length();j++)
cout<<s[j];
cout<<"\n";
}
return 0;
}
1 Like
Heyy thanks everyone please be there to help, this way we’ll learn better and faster