第二个空填s>1程序应该也没错啊,为什么答案只能是s>0呢?
附题目代码
#include <stdio.h>
unsigned long fun(unsigned long n)
{ unsigned long x=0, s, i; int t;
s=n;
/**********found**********/
i=1;
/**********found**********/
while(s>0) //第二空
{ t=s%10;
if(t%2==0){
/**********found**********/
x=x+t*i; i=i*10;
}
s=s/10;
}
return x;
}
main()
{ unsigned long n=-1;
while(n>99999999||n<0)
{ printf("Please input(0<n<100000000): "); scanf("%ld",&n); }
printf("\nThe result is: %ld\n",fun(n));
}
可能s>1和s>0得到的结果是一样的,但逻辑上s>0更严谨,1确实不满足循环中的if条件,但不满足if条件的那么多,你为啥非要在while这儿就把1排除了呢?