#include
int main(int argc, char *argv[]) {
int num, ge, shi, bai, qian, wan, count; //num是输入的数据,count用来记录位数
//ge,shi,bai,qian,wan分别表示数据的个、十、百、千、万位数字
scanf("%d", &num);//输入数据
//下属if else if语句功能是判断输入的数据是多少位,根据结构补充完整代码
if (num >9999) {
count = 1;
} else if (num >999) {
count = 2;
} else if (num >99) {
count = 3;
} else if (num >9) {
count = 4;
} else {
count = 5;
}
printf("位数:%d\n", count);
printf("每位数字为: ");
wan = num / 10000;
qian = num / 1000 % 10;
bai = num / 100 % 10;
shi = num / 10 % 10;
ge = num % 10;
//下述switch语句功能是根据输入数据的位数,反序输出对应数据
switch (count) {
case 5:
printf("%d%d%d%d%d\n", wan, qian, bai, shi, ge);
printf("反序数字为:");
printf("%d%d%d%d%d\n", ge, shi, bai, qian, wan);
break;
case 4:
printf("%d%d%d%d\n", qian, bai, shi, ge);
printf("反序数字为:");
printf("%d%d%d%d\n", ge, shi, bai, qian);
break;
case 3:
printf("%d%d%d\n", bai, shi, ge);
printf("反序数字为:");
printf("%d%d%d\n", ge, shi, bai);
break;
case 2:
printf("%d%d\n", shi, ge);
printf("反序数字为:");
printf("%d%d\n", ge, shi);
break;
case 1:
printf("%d\n", ge);
printf("反序数字为:");
printf("%d\n", ge);
break;
}
return 0;
}
你是否还在寻找稳定的海外服务器提供商?创新互联www.cdcxhl.cn海外机房具备T级流量清洗系统配攻击溯源,准确流量调度确保服务器高可用性,企业级服务器适合批量采购,新人活动首月15元起,快前往官网查看详情吧