求一个不多于5位正整数是几位数,下面是我弄的......总是输出4
程序代码:
[code]#include<stdio.h> main() { int num; printf("please input a number less than 99999 and more than 0\n"); scanf("%d",num); if (num<=9)printf("1 place"); else if (num>=10,num<=99)printf("2 place"); else if (num<=999)printf("3 place"); else if (num<=9999)printf("4 place"); else if (num<=99999)printf("5 please"); return 0; }[/code]
还有一个
程序代码:
#include<stdio.h> main() { int num,place; printf("please input a number less than 99999 and more than 0\n"); scanf("%d",num); if (num<=9)place=1; else if (num>=10,num<=99)place=2; else if (num>=100,num<=999)place=3; else if (num>=1000,num<=9999)place=4; else if (num>=10000,num<=99999)place=5; printf("place=%d",place); return 0; }
不知道为什么,输出结果总是不变