头插法的循环做不了
#include <stdio.h>
#include <stdlib.h>
#define Elemtype int
#define ok 1
#define error 0
typedef struct Node{
Elemtype data;
struct Node *next;
}*Linklist;
//初始化
void Initlist(Node *p){
p=(Linklist)malloc(sizeof(Node));
p->next=NULL;
}
//头插法建表
void Creatlist(Node *p){
int k=0;
char c;
Node *r;
int flag=1;
while(flag){
c=getchar();
if(c!='$'){
r=(Linklist)malloc(sizeof(Node));
r->data=c;
r->next=p->next;//?
p->next=r;
k++;
}
else{
flag=0;
}
}
}
//输出
void Output(Node *m){
while(m->next!=NULL){
printf("%d",m->data);
m=m->next;
}
}
int main(){
void Initlist(Node *p);
void Creatlist(Node *p);
void Output(Node *m);
Node *L;
Initlist(L);
Creatlist(L);
Output(L);
}