请耐心看下
#include<iostream>
using namespace std;
int tar[46]={2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,
53,59,61,67,71,73.79,83,87,89,101,103,107,
109,113,127,131.137,139,149,151,157,163,167,
173,179,181,191,193,197,199};
int main()
{
int i=0;
while(i<46)
{
cout<<tar[i]<<endl;
i++;
}
return 0;
}
上面是200以内的素数 ,他本应该输到149 就停了,不过后却多输出了两个0;
结果
2
3
5
7
.
.
149
0
0
Pess any key to continue
重新拟了一个数组:int tar[46]={1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,
16,17,18,19,20,21,22,23,24,25,26,27,28,
29,30,31,32,33,34,35,36,37,38,39,
40,41,42,43,44,45,46};
用来测试 一却正常 请问高手们 出现这问题原因是什么? |