#include
using namespace std;
int main()
{
int n;
int i=0;
cout<<"please input number:";
cin>>n;
int a[6];
if(n/100000 >= 1)
{
i = 6;
a[0] = n%10;
a[1] = (n/10)%10;
a[2] = (n/100)%10;
a[3] = (n/1000)%10;
a[4] = (n/10000)%10;
a[5] = (n/100000)%10;
}
else if(n/10000 >= 1)
{
i = 5;
a[0] = n%10;
a[1] = (n/10)%10;
a[2] = (n/100)%10;
a[3] = (n/1000)%10;
a[4] = (n/10000)%10;
}
else if(n/1000 >= 1)
{
i = 4;
a[0] = n%10;
a[1] = (n/10)%10;
a[2] = (n/100)%10;
a[3] = (n/1000)%10;
}
else if(n/100 >= 1)
{
i = 3;
a[0] = n%10;
a[1] = (n/10)%10;
a[2] = (n/100)%10;
}
else if(n/10>= 1)
{
i = 2;
a[0] = n%10;
a[1] = (n/10)%10;
}
else
{
i = 1;
a[0] = n;
}
switch (i)
{
case 6:cout<<"6位数"<case 5:cout<<"5位数"< case 4:cout<<"4位数"< case 3:cout<<"3位数"< case 2:cout<<"2位数"< case 1:cout<<"1位数"< default: break;
}
return 0;
}
说实话 这个必须用嵌套if判断和必须用switch输出...有点蠢