S1E21作业,第三道操作题不输出,求大佬们看看
本帖最后由 BlackWhite_idea 于 2021-12-26 16:05 编辑#include <stdio.h>
int main()
{
int count, gride, n, i, j, sum = 0;
char answer;
_Bool result = 1;
printf("输入一个整数:");
scanf("%d", count);
int text;
for (n = 3; n <= count; n++)
{
for(i=0;i<4;i++)
{
text = 0;
}
}
for (n = 3; n <= count; n++)
{
gride = n * n * n;
for (i = 1; i < gride; i += 2)
{
for (j = i; j < gride; j += 2)
{
sum += j;
if (sum == gride)
{
text = gride;
text = i;
text = i + 2;
text = j;
goto liu;
}
if (sum > gride)
{
sum = 0;
break;
}
}
}
liu:
sum = 0;
}
for(n=3;n<=count;n++)
{
if(text==0)
{
result = 0;
break;
}
}
if (result)
{
printf("3~%d之间所有的整数均符合尼科彻斯定理!\n\n", count);
printf("是否打印所有式子:(y/n):");
getchar();
scanf("%c", &answer);
}
else
{
printf("未找到符合定义的整数!");
}
if (answer == 'y' || answer == 'Y')
{
for (n=3;n<=count;n++)
{
if (text - text > 4)
{
printf("%d^3 == %d == %d + %d + ... + %d\n", n, text, text, text, text);
}
else
{
printf("%d^3 == %d == %d + %d + %d\n", n, text, text, text, text);
}
}
}
}
为什么不出输出。。 才发现原来是scanf里少了个&
页:
[1]