#include<stdio.h>
int main()
{int num,n;
printf("请输入一个不大于5位的正整数!\n");
scanf("%d",&num);
if (num<=9) n=1;
else if (num<=99) n=2;
else if (num<=999) n=3;
else if (num<=9999) n=4;
else if (num<=99999) n=5;
printf("%d是%d位数!",num,n);
if (num>=99999);
printf("%d输入错误无法提供几位数",num);
return 0;
}
#include <stdio.h>
int main()
{
int num, n;
printf("请输入一个不大于5位的正整数!\n");
scanf("%d", &num);
if (num <= 9)
n = 1;
else if (num <= 99)
n = 2;
else if (num <= 999)
n = 3;
else if (num <= 9999)
n = 4;
else if (num <= 99999)
n = 5;
if (num >= 99999)//;
printf("%d输入错误无法提供几位数", num);
else
printf("%d是%d位数!", num, n);
return 0;
}
nun<=99这样逻辑才严谨