Home > Back-end >  It seems to appear in the C illegal memory access!!
It seems to appear in the C illegal memory access!!

Time:09-23

A great god, please help have a look at why the illegal memory access!!

#include
using namespace std;

Int main ()
{
Int shu1;
Int shu2;
Cin & gt;> Shu1;
Cin & gt;> Shu2;
Int * p=new int [shu1];
Int * q=new int [shu2];
Int * z=new int [shu1 + shu2];
Int min, useful;

for (int i=0; i {
Cin & gt;> P [shu1];
}
for (int i=0; i {
Cin & gt;> Q [shu2];
}
For (int j=0; J & lt; Shu1; J++)
{
Z [j]=p [j];
}
For (int a=shu1; A. & lt; Shu1 + shu2; +)
{
int i=0;
If (I & lt; Shu2)
{
[a]=z q [I];
i++;
}
}

For (int h=0; H & lt; Shu1 + shu2; H++)
{
Min=z [h];
For (int hh=0; Hh & lt; Shu1 + shu2; Hh++)
{
If (hh & lt; Min)
{
Useful=z [h];
[h] z=z (hh);
Z (hh)=useful;
}
}
}

For (int counter=0; Counter & lt; Shu1 + shu2; Counter++)
{
Cout & lt; }
The delete [] p;
The delete [] q;
The delete [] z;
System (" Pause ");
}

This is a topic!!!!!
Combine two ascending order integer array to an array of ascending, asked to input the length of the two arrays, respectively, to input data respectively, design algorithm, in order to get high efficiency,

  • Related