Sunday, 11 March 2018

Reverse The Number

Reverse The Number

All submissions for this problem are available.
If an Integer N, write a program to reverse the given number.

Input

The first line contains an integer T, total number of testcases. Then follow T lines, each line contains an integer N.

Output

Display the reverse of the given number N.

Constraints

  • 1  T  1000
  • 1  N  100000

Example

Input
4
12345
31203
2123
2300
Output
54321
30213
3212
32

Solution

  1. #include<stdio.h>
  2. int main()
  3. { int t,i,d;
  4. long a;
  5. scanf("%d",&t);
  6. while(t--)
  7. { long s=0;
  8. scanf("%ld",&a);
  9. while(a!=0){
  10. d=a%10;
  11. s=s*10+d;
  12. a=a/10;
  13. }
  14. printf("%ld\n",s);
  15. }
  16. }

No comments:

Post a Comment

Reverse The Number

Reverse The Number All submissions for this problem are available. If an Integer   N , write a program to reverse the given number. ...