main()
{
int n,j,k,l;
printf("INPUT n=");
do
{
scanf("%d",&n);
k=n*n-n+1,l=n*n+n-1;
for(j=0;k<=l;k+=2)
{ printf(" %d",k);
j+=k;
}
if(j=n*n*n) printf("sum=%d=n*n*n\n",j);
else printf("sum=%d!=n*n*n\n",j);
}
while(n!=0);
}
学长,这样写可以吗?
{
int n,j,k,l;
printf("INPUT n=");
do
{
scanf("%d",&n);
k=n*n-n+1,l=n*n+n-1;
for(j=0;k<=l;k+=2)
{ printf(" %d",k);
j+=k;
}
if(j=n*n*n) printf("sum=%d=n*n*n\n",j);
else printf("sum=%d!=n*n*n\n",j);
}
while(n!=0);
}
学长,这样写可以吗?
[此贴子已经被作者于2006-12-5 11:56:09编辑过]