| 
 | 
 
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册  
 
x
 
 本帖最后由 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[count][4];
 
  
-     for (n = 3; n <= count; n++)
 
 -     {
 
 -         for(i=0;i<4;i++)
 
 -         {
 
 -             text[n][i] = 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[n][0] = gride;
 
 -                     text[n][1] = i;
 
 -                     text[n][2] = i + 2;
 
 -                     text[n][3] = j;
 
  
-                     goto liu;
 
 -                 }
 
  
-                 if (sum > gride)
 
 -                 {
 
 -                     sum = 0;
 
 -                     break;
 
 -                 }
 
 -             }
 
 -         }
 
 -     liu:
 
 -         sum = 0;
 
 -     }
 
  
-     for(n=3;n<=count;n++)
 
 -     {
 
 -         if(text[n][0]==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[n][3] - text[n][1] > 4)
 
 -             {
 
 -                 printf("%d^3 == %d == %d + %d + ... + %d\n", n, text[n][0], text[n][1], text[n][2], text[n][3]);
 
 -             }
 
 -             else
 
 -             {
 
 -                 printf("%d^3 == %d == %d + %d + %d\n", n, text[n][0], text[n][1], text[n][2], text[n][3]);
 
 -             }
 
 -         }
 
 -     }
 
 - }
 
  复制代码 
 
 
为什么不出输出。。 |   
 
 
 
 |