#include<stdio.h>
int main()
{
/*求0-7所能组成的奇数的个数*/
long sum=4, s=4;
int j;
for (j=2; j<=8; ++j)
{
printf("\n%ld", sum);
if (j<=2)//最高位不能为0
s*=7;//s=s*7;
else
s*=8;//s=s*8;
sum+=s;
}
printf("\nsum=%ld",sum);
return 0;
}
#include<stdio.h>
int main()
{
/*求0-7所能组成的奇数的个数*/
long sum=4, s=4;
int j;
for (j=2; j<=8; ++j)
{
printf("\n%ld", sum);
if (j<=2)//最高位不能为0
s*=7;//s=s*7;
else
s*=8;//s=s*8;
sum+=s;
}
printf("\nsum=%ld",sum);
return 0;
}
转载于:https://www.cnblogs.com/wangjingyuwhy/archive/2013/03/01/2939521.html