2020-04-03
#include<stdio.h>
int main()
{
char s[10] ={0},ch =0;
int n, cnt=0, i =0,flag = 0;
do
{
printf("输入一个10~1000的正整数(不包含10和1000):");
scanf("%d", &n);
}while((n <= 10)||(n >= 1000));
while(n > 0)
{
s[cnt++] = n%10;
n /= 10;
}
switch(cnt)
{
case 2:
{
if (s[0] == s[1])
{
flag = 1;
}
ch =s[0];
s[0]=s[1];
s[1]=ch;
break;
}
case 3:
{
if (s[0] == s[2])
{
flag = 1;
}
ch =s[0];
s[0]=s[2];
s[2]=ch;
break;
}
default: break;
}
printf("它是%d位数\n",cnt);
for(i = 0; i<cnt; i++)
{
printf("%d ", s[i]);
}
printf("\n");
if (flag == 1)
{
printf("相同\n");
}
else
{
printf("不相同\n");
}
return 0;
}
2020-04-03