reverse the position of integer digits?

后端 未结 13 2816
予麋鹿
予麋鹿 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:37

    int a,b,c,d=0;
    cout<<"plz enter the number"<>a;
    b=a;
    do
    {
        c=a%10;
        d=(d*10)+c; 
        a=a/10;
    }
    while(a!=0);
    cout<<"The reverse of the number"<

    }

提交回复
热议问题