Home > Back-end >  [C] internal compiler error
[C] internal compiler error

Time:12-29

Compile environment: visual studio2019

Said I overflow at the beginning, then I push the stack, and the results have been tip is to rewrite the

And display the error

Source:
 
#include
#include
#include
# define INF 32767
# define MAXSIZE 1000
# define N 5
Typedef int elemtype;
Int adjacency_array [N] [N]={{0, 6, INF, 2, and INF},
{INF, 0, 10, INF, 3},
{INF, INF, 0, INF, 8},
{INF, INF, 1, 0, INF},
{INF, INF, INF, 12, 0}};
Int visited_deep [N * N]={0};
Typedef struct node {//define a node adjacency table data type
int id;//node number
Struct node * pnext;//pointer to the next node
Int weight;//lead to the edge of the next node weights
} the Node;
Typedef struct {//define a graph adjacency list data type
Node * headnode [MAXSIZE];
Int vertex.//vertices
Int edge;//number of edges
} Graph;

Typedef struct {
The int data [MAXSIZE];
Int the head;
Int tail;
} the Queue;
Typedef struct {
//define the adjacency matrix of the data type
Elemtype vex [MAXSIZE];
Int the arc [MAXSIZE] [MAXSIZE];
Int e, n.
} graph;
Int locatevex (graph g, elemtype v)
{
int i;
for (i=0; I & lt; G.n. I++) if (g.v ex [I]==v) return the I;
return -1;
}
Void creat_graph_adjacency_list (Graph * pgraph, int vertex, int edge);
Void print_graph (Graph * pgraph);
* * ppgraph void distory_graphy (Graph);
Void deep_first_search (Graph * pgraph, int start);
Void breadth_first_search (Graph * pgraph, int start);
Void in_queue (Queue * q, int id);
Void out_queue Queue * q, int * (temp);
The main () {
Graph * pgraph=(Graph *) calloc (1, sizeof (Graph));
Creat_graph_adjacency_list (pgraph, N, 7);
Printf (" the picture of the adjacency matrix is: \ n ");
Graph (pgrah);
Printf (" the picture of the adjacency list is: \ n ");
Print_graph (pgraph);
Printf (" the picture of a depth-first traversal sequence is: \ n ");
Deep_first_search (pgraph, 0);
Printf (" \ n the picture of a breadth-first traversal sequence is: \ n ");
Breadth_first_search (pgraph, 0);
Distory_graphy (& amp; Pgraph);
return 0;
}
Void create_graph_array (graph * G) {
Int I, j, k, w;
for (i=0; I & lt; 12. I++) {
For (j=0; J & lt; 12. J++) {
G - & gt; The arc [I] [j]=INF;
}
}
}
Void creat_graph_adjacency_list (Graph * pgraph, int vertex, int edge) {//create Graph adjacency list
int i, j;
for (i=0; I & lt; Vertex. I++) {
Pgraph - & gt; Headnode [I]=NULL;
}
for (i=0; I & lt; Vertex. I++) {
For (j=vertex - 1; J & gt;=0; J -) {
If (adjacency_array [I] [j].=0 & amp; & Adjacency_array [I] [j]. INF)={
Node * pnew=(*) calloc (1, sizeof (Node));
Pnew - & gt; Id=j;
Pnew - & gt; Weight=adjacency_array [I] [j];
Pnew - & gt; Pnext=pgraph - & gt; Headnode [I];//head interpolation to create singly linked list
Pgraph - & gt; Headnode [I]=pnew;
}
}
}
Pgraph - & gt; Vertex=vertex;
Pgraph - & gt; Edge=edge;
return;
}
Void print_graph (Graph * pgraph) {//print the adjacency list
int i;
Node * phead;
If (pgraph==NULL) {
Printf (" The graph is empty! \n");
}
The else {
for (i=0; I & lt; Pgraph - & gt; Vertex. I++) {
Phead=pgraph - & gt; Headnode [I];
Printf (" % d ", I);
While (phead!=NULL) {
Printf (" % d % [d] - & gt; "Phead - & gt; Id, phead - & gt; Weight);
Phead=phead - & gt; Pnext;
}
Printf (" NULL \ n ");
}
}
Free (phead);
Phead=NULL;
return;
}
* * ppgraph void distory_graphy (Graph) {//destruction of adjacency list
int i;
Ppre Node * and * pcur;
for (i=0; I & lt; (* ppgraph) - & gt; Vertex. I++) {
Ppgraph ppre=(*) - & gt; Headnode [I];
If (ppre!=NULL) {
Pcur=ppre - & gt; Pnext;
While (pcur!=NULL) {
Free (ppre);
Ppre=pcur;
Pcur=pcur - & gt; Pnext;
}
Free (ppre);
}
The else {
Free (ppre);
Ppre=NULL;
}
}
Free (* ppgraph);
* ppgraph=NULL;
return;
}
Void deep_first_search (Graph * pgraph, int start) {//depth-first traversal
Node * p;
Visited_deep [start]=1;
Printf (" % d ", start);
P=pgraph - & gt; Headnode [start];
while (p !=NULL) {
If (visited_deep [p - & gt; id]==0) {
Deep_first_search (pgraph, p - & gt; Id);
}
P=p - & gt; Pnext;
}
return;
}
Void breadth_first_search (Graph * pgraph, int start) {//breadth-first traversal
The Queue * q=(Queue *) calloc (1, sizeof (Queue));
Q - & gt; The head=0;
Q - & gt; Tail=0;
Int visited [N * N]={0};
int temp;
Node * pcur;

Printf (" % d ", start);
Visited [start]=1;
In_queue (q, start);
While (q - & gt; Tail!=q - & gt; The head) {//circular queue is not empty
Out_queue (q, & amp; Temp);
Pcur=pgraph - & gt; Headnode (temp);
While (pcur!=NULL) {//all adjacent points of traverse pcur
If (visited [pcur - & gt; id]==0) {
Printf (" % d ", pcur - & gt; Id);
Visited [pcur - & gt; id]=1;
In_queue (q, pcur - & gt; Id);
}
Pcur=pcur - & gt; Pnext;
}
}
return;
}
Void in_queue (Queue * q, int id) {//into the stack circular Queue
If ((q - & gt; Tail MAXSIZE==+ 1) % q - & gt; The head) {
Printf (" The queue is full! \n");
}
The else {
Q - & gt; Tail=(q - & gt; Tail + 1) % MAXSIZE;
Q - & gt; Data [q - & gt; tail]=id;
}
return;
}

nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull
  • Related