Home > Back-end >  It stopped with signal sigsegv, solving
It stopped with signal sigsegv, solving

Time:10-11

#include
#include
using namespace std;
Const int MaxSize=100;
The class SeqList
{
Private:
The int data [MaxSize];
int length;
Public:
SeqList ();
SeqList (int a [], int n);
~ SeqList () {}
Void SetData (int a [], int n);
Int GetLength ();//get the array length
Int the Get (int I);//by a lookup function
};
Void InputLength (int n);//input array length
Void Inputdata (SeqList A, SeqList B);//input function
A, void CombineArray (SeqList SeqList B, SeqList C);//to realize the merger of the linear table

Int main ()
{
SeqList list1, list2, list3;
Inputdata (list1, list2);
CombineArray (list1, list2, list3);
return 0;
}
SeqList: : SeqList ()
{
Length=0;
}
SeqList: : SeqList (int * a, int n)
{
If (n> MaxSize) throw "illegal" parameter;
For (int j=0; j{
Data [j]=a, [j].
}
Length=n;
}
Void SeqList: : SetData (int a [], int n)
{
If (n> MaxSize) throw "illegal" parameter;
For (int j=0; j{
Data [j]=a, [j].
}
Length=n;
}
Int SeqList: : GetLength ()
{
Return length;
}
Int SeqList: : Get (int I)
{
If (i<1 | | i> Length) throw "illegal" find position;
The else
{
The return data [I - 1);
}
}
Void InputLength (int n)
{
Cout<& lt;" Please enter the array length: ";
Cin> n;
}
Void Inputdata (SeqList A, SeqList B)
{
int n;
InputLength (n);
Int a [n].//////////////debugging to this wrong
Cout<& lt;" Please enter A orderly array data: ";
for(int i=0; i{
Cin> A, [I].
}
A.S etData (a, n);
int m;
InputLength (m);
Int b [m];
Cout<& lt;" Please input orderly array data B: ";
For (int j=0; j{
Cin> B [j];
}
B.S etData (b, m);
}
A, void CombineArray (SeqList SeqList B, SeqList C)
{
int i=0;
int j=0;
Int k=0;
Int n=al-qeada etLength ();
Int m=B.G etLength ();
Int c [m + n];
While (i{
If (al-qeada et (I) & lt;=B.G et (j))
{
C [k]=B.G et (j);
k++;
j++;
}
The else
{
C [k]=al-qeada et (I);
k++;
i++;
}
}
}

CodePudding user response:

Visit the invalid memory