Home > Back-end >  Throw an exception: [for] code read access conflicts
Throw an exception: [for] code read access conflicts

Time:04-03

#include
using namespace std;
# define LEN sizeof (struct student)

Struct student
{
Long num.
int score;
Struct student * next;
};

Struct student lista, by;
Int n, sum=0;

Int main ()
{
Struct student * creat (void);
Struct student * insert (struct student *, struct student *);
Void print (struct student *);
Abh bhead ahead, struct student * *, *.
Printf (" input a list a: \ n ");
Ahead=creat ();
Sum=sum + n.
Printf (" input the list b: \ n ");
Bhead=creat ();
Sum=sum + n.
Abh=insert (ahead, bhead);
Print (abh);
return 0;
}

Struct student * creat (void)
{
Struct student * (p1, p2, * head;
N=0;
P1=p2=(struct student *) malloc (LEN);
Printf (" input the number & amp; Scores of student: \ n ");
Printf (" if the number is 0, the stop inputing. \ n ");
The scanf (" % ld, % d ", & amp; P1 - & gt; Num, & amp; P1 - & gt; Score);
The head=NULL;
While (p1 - & gt; Num!=0)
{
n=n + 1;
If (n==1)
The head=p1;
The else
The p2 - & gt; Next=p;
P1 p2=;
P1=(struct student *) malloc (LEN);
The scanf (" % ld, % d ", & amp; P1 - & gt; Num, & amp; P1 - & gt; Score);
}
The p2 - & gt; Next=NULL;
Return (the head);
}

Struct student * insert (struct student * ah, struct student * bh)
{
Pb1 pa2 pa1 struct student * and * and *, * pb2;
Pa2=pa1=ah;
Pb2=pb1=bh;
Do
{
While ((pb1 - & gt; Num & gt; Pa1 - & gt; Num) & amp; & (pa1 - & gt; Next!=nullptr))
{
Pa2=pa1;
Pa1=pa1 - & gt; Next;
}
If (pb1 - & gt; Num & lt;=pa1 - & gt; Num)
{
If (ah==pa1)
Ah=pb1;
The else
Pa2 - & gt; Next=pb1;
Pb1=pb1 - & gt; Next;
Pb2 - & gt; Next=pa1;
Pa2=pb2;
Pb2=pb1;
}
} while ((pa1 - & gt; Next!=NULL) | | (pa1==NULL & amp; & Pb1!=NULL));
If ((pb1!=NULL) & amp; & (pb1 & gt; Num & gt; Pa1 - & gt; Num) & amp; & (pa1 - & gt; Next==NULL))
Pa1 - & gt; Next=pb1;
Return (ah);
}

Void print (struct student * head)
{
Struct student * p;
Printf (" There are % d records: \ n ", sum);
P=the head;
If (p!=NULL)
Do
{
Printf (" % ld % d \ n ", p - & gt; Num, p - & gt; Score);
P=p - & gt; Next;
} while (p!=NULL);
}

This is a code,
Why will appear this kind of mistake how to solve
  • Related