#include <iostream>
using namespace std;
int main()
{
int a,temp;
int ten_thousand,thousand,hundred,ten,indiv;
cin>>a;
if(a>9999)
temp=5;
else if(a>999)
temp=4;
else if(a>99)
temp=3;
else if(a>9)
temp=2;
else temp=1;
cout<<temp<<endl;
ten_thousand=a/10000;
thousand=(a-ten_thousand*10000)/1000;
hundred=(a-ten_thousand*10000-thousand*1000)/100;
ten=(a-ten_thousand*10000-thousand*1000-hundred*100)/10;
indiv=a-ten_thousand*10000-thousand*1000-hundred*100-ten*10;
switch(temp)
{
case 5:cout<<ten_thousand<<" "<<thousand<<" "<<hundred<<" "<<ten<<" "<<indiv<<endl;
cout<<indiv<<" "<<ten<<" "<<hundred<<" "<<thousand<<" "<<ten_thousand<<endl;
break;
case 4:cout<<thousand<<" "<<hundred<<" "<<ten<<" "<<indiv<<endl;
cout<<indiv<<" "<<ten<<" "<<hundred<<" "<<thousand<<endl;
break;
case 3:cout<<hundred<<" "<<ten<<" "<<indiv<<endl;
cout<<indiv<<" "<<ten<<" "<<hundred<<endl;
break;
case 2:cout<<ten<<" "<<indiv<<endl;
cout<<indiv<<" "<<ten<<endl;
break;
case 1:cout<<indiv<<endl;
cout<<indiv<<endl;
break;
}
return 0;
}
给出一个数,不多于五位,1.求出他是几位数2.分别打印出每位数3.倒序输出
最新推荐文章于 2021-02-02 12:31:26 发布