为什么这段代码会出现这个错误
程序代码:
#include <ctime> #include <iostream> using namespace std; /*--------判断重复数值和输出重复数值个数------*/ void filter(int *p,int count,int &succeed1); /*--------从小到大地输出数值------*/ void taxis(int *p,int count,int succeed1); int main(int argc, char* argv[]) { int count; //个数 int incept; //接收 int succeed1=0; //判断重复的个数 cin>>count; srand((unsigned)time(NULL)); int *p=new int[count]; for(int i=0;i<count;i++) { incept=rand()%100; p[i]=incept; } for(int z=0;z<count;z++) { if(z%10==0&&z>0) { cout<<endl; } cout<<p[z]<<" "; } filter(p,count,succeed1); taxis(p,count,succeed1); delete [] p; return 0; } void filter(int *p,int count,int &succeed1) { int *p2=new int[count]; for(int hh=0;hh<count;hh++) { p2[hh]=0; } for(int i=0;i<count;i++) { for(int j=0;j<count;j++) { p2[p[i]]++; } } for(int j=0;j<count;j++) { if(p2[j]>1) // 等于100,说明是重复的 succeed1++; } delete[] p2; } void taxis(int *p,int count,int succeed1) { int temporary; cout << endl << "------------------>" << succeed1 << endl; for(int i=0;i<count;i++) { for(int j=0;j<count;j++) { if(p[i]<p[j]) { temporary=p[i]; p[i]=p[j]; p[j]=temporary; } } } for(int z=0;z<count;z++) { if(z%10==0&&z>0) { cout<<endl; } cout<<p[z]<<" "; } cout<<endl; }
输入10的时候就会出现这玩意,这个是怎么回事导致的?