#include <iostream>using namespace std;int main(){long int a=0,t=0,y=0,j=0;int i,f=0,o,x=1,c=1,k=1;cout<<"請輸入一個正整數(10位以內):";cin>>a;t=a;for(i=10;t>10;) { x++;t/=10; } //得出是幾位數(x);f=o=x;for(;o>1;o--) c*=10;//c=10的x次方;c=c*10;for(;f>0;f--){y=((a/(c/10)-(a/c)*10)*k);c/=10;k*=10;j+=y;}cout<<"您輸入的數是"<<x<<"位數。";cout<<"您輸入的數倒過來是:"<<j<<"\n";return 0;}
- 2 回答
- 0 關注
- 1585 瀏覽
添加回答
舉報
0/150
提交
取消