guanmeige @ 2016-12-21 16:10:26
#include <cstdlib>
#include <iostream>
using namespace std;
bool prime[20005];
int n, i, j;
int main(int argc, char *argv[])
{
cin >> n;
for (i = 1; i <= 20000; i++)
prime[i] = true;
for (i = 2; i <= 10000; i++)
for (j = i; j <= 20000; j += i)
prime[j] = false;
for (int a = 2; a <= n - 4; a++)
for (int b = 2; b <= n - 4; b++)
{
int c = n - a - b;
if (prime[a] && prime[b] && prime[c])
{
cout << a << " " << b << " " << c << endl;
break;
}
}
system("PAUSE");
return EXIT_SUCCESS;
}
by nonanalyzer @ 2017-01-25 17:50:03
暂停的语句删掉,最后一句return 不要,循环里的那个break改成return 0;
by nonanalyzer @ 2017-01-25 17:50:41
筛质数的方法不知道有没有错