Home > other >  C language data structure and algorithm singly linked lists interpolation
C language data structure and algorithm singly linked lists interpolation

Time:03-10

program compiled no problem but time will not stop running have been output digital

The code is as follows:

 # include & lt; stdio.h> 
#include
# define MAXSIZE 100
Int I=0, n, a, [MAXSIZE].

Typedef struct LNode {
The int data;
Struct LNode * next;
} LNode;

Void creatlist (LNode * C, int a [], int n) {

LNode * s * r;
C=(LNode *) malloc (sizeof (LNode));
C - & gt; Next=NULL;
R=C;
for(i=0; iS=(LNode *) malloc (sizeof (LNode));
S - & gt; data=https://bbs.csdn.net/topics/a [I];
R - & gt; Next=s;
R=r - & gt; Next;
}
R - & gt; Next=NULL;

}

Int printlist (LNode * C, int n) {//want to look at the output
for(i=0; i
Printf (" % d, C - & gt; The data);
C=C - & gt; Next;
}
Printf (" % d, C - & gt; The data);
}

Int main () {
LNode * C.
C=(LNode *) malloc (sizeof (LNode));


Printf (" please input you want the number of elements in the input: ");
The scanf (" % d ", & amp; n);
Printf (" please enter your input elements: ");
for(i=0; iThe scanf (" % d ", & amp; A [I]);
}

Creatlist (C, a, n);//I write that right?
Printlist (C, n);//I write that right?
return 0;
}


The tail interpolation algorithm is a reference book, pictures are as follows:


Also want to ask in the first row picture of LNode * & amp; C, what? Books on type is a pointer variable in a function body rewrite spelled, but in the compiler complains, is this why? Also want to ask & amp; "" And what is the difference between "*"?

I was a small white, hope someone can guide, if you know that part of the answer to the question, also hope to glad, don't need a full answer,

CodePudding user response:

* (pointer) is a pointer reference
& Is the value
  • Related