有事请教,希望大家能指点迷津!先谢谢了
#include "stdafx.h"
#include <iostream>
#include <conio.h>
#include <iomanip>
using std::cin;
using std::cout;
using std::endl;
using std::setw;
int _tmain(int argc, _TCHAR* argv[])
{
long* pprime = NULL;
long begin = 5;
int flag = 0;
int count = 3;
int MAX = 4;
cout << "Enter the number of primes would you like(at least 4):";
cin >> MAX;
if(MAX < 4)
MAX = 4;
pprime = new long[MAX];
*pprime = 2;
*(pprime + 1) = 3;
*(pprime + 2) = 5;
for(;count <= MAX;)
{
begin += 2;
flag = 0;
for(int i=0;i<=count;i++)
{
flag = begin % *(pprime + i) == 0;
break;
}
if(flag == 0)
*(pprime + count++) = begin;
}
for(int i = 0;i < MAX;i++)
{
if(i % 5 == 0)
cout << endl;
cout << setw(10) << *(pprime + i);
}
delete [ ] pprime;
pprime = 0;
cout << endl;
cout<<"press any key...";
_getch();
return 0;
}
为什么最后不能按任意键结束?只能点右上角的关闭才能关?