啊哈磊_编程从这里起步

标题: 错误 [打印本页]

作者: 嗝~    时间: 2019-5-1 21:40
标题: 错误
  1. #include <iostream>
  2. #include <cstdio>
  3. using namespace std;
  4. int main()
  5. {
  6.     int k,a,b,i,count1,count2;
  7.     for(k=4;k<=100;k=k+2)
  8.     {
  9.         for(a=2;a<=k/2;a++)
  10.         {
  11.             count1=0;
  12.             for(i=2;i<=a-1;i++)
  13.             {
  14.                 if(a%i==0)
  15.                 {
  16.                     count1++;
  17.                     break;
  18.                 }
  19.             }
  20.             if(count1==0)
  21.             {
  22.                 b=k-a;
  23.                 count2=0;
  24.                 for(i=2;i<=b-1;i++)
  25.                 {
  26.                     if(b%i==0)
  27.                     {
  28.                         count2++;
  29.                         break;
  30.                         
  31.                     }
  32.                 }
  33.                 if(count2==0)
  34.                 {
  35.                     printf("%d=%d+%d",k,a,b);
  36.                     break;
  37.                 }
  38.             }
  39.         }
  40.     }
  41.     system("pause");
  42.     return 0;
  43. }
复制代码

作者: lijinze    时间: 2019-5-22 19:31






欢迎光临 啊哈磊_编程从这里起步 (https://bbs.codeaha.com/) Powered by Discuz! X3.2