新手求助,谢谢!编译通过,但只能输出0
#include<stdio.h>int main()
{
int a[1000000]={0},b[1000000]={0};
int i=0, x, y, z, n=1, j=1,num=0;
scanf("%d",&x);
y=x;
z=x;
while (y>0)
{
n++;
y=y/10;
}
for (i = 0;i < n;i++)
{
a[i] = z%10;
z = z/10;
}
for (i = 0;i < n;i++)
{
if ((a[i] % 2)!= (i+1) % 2)
b[i] = 1;
}
for (i = 0;i < n;i++)
{
num = num+(b[i] * j);
j = j*2;
i++;
}
printf("%d\n",num);
return 0;
}
顺便说一下,这是一道数字特征题,谢谢各位大神的帮助!
[此贴子已经被作者于2015-12-21 21:31编辑过]