reverse the position of integer digits?

后端 未结 13 2510
予麋鹿
予麋鹿 2021-02-09 15:00

i have to reverse the position of integer like this

input = 12345

output = 54321

i made this but it gives wrong output e.g 5432

#include         


        
13条回答
  •  长情又很酷
    2021-02-09 15:26

    I have done this simply but this is applicable upto 5 digit numbers but hope it helps

     #include
        using namespace std;
    void main()
    { 
        int a,b,c,d,e,f,g,h,i,j;
        cin>>a;
        b=a%10;
        c=a/10;
        d=c%10;
        e=a/100;
        f=e%10;
        g=a/1000;
        h=g%10;
        i=a/10000;
        j=i%10;
        cout<

提交回复
热议问题