金陵科技学院实验报告
} main() {
int i,k; chuan *head; head=setup(s);
printf(\请输入要删除字符的位置i\\n\); scanf(\,&i);
printf(\请输入要删除字符的个数k\\n\); scanf(\,&k); delet(head,i,k); display(head); free(head); free(s); }
}
printf(\,p->c); while(p->next!=NULL) { }
p=p->next;
printf(\,p->c);
2.
#include
char c;
struct chuanlian *next;
}chuan; chuan *s,*t;
chuan *setup(chuan *chu) {
chuan *head=NULL; chuan *rear=NULL;
金陵科技学院实验报告
char ch;
printf(\请输入字符ch直到$\\n\ch=getchar(); while(ch!='$') {
chu=malloc(sizeof(chuan)); }
void insert(chuan *s1,chuan *s2,char x) {
chuan *p; chuan *q; p=s1; if(s1==NULL) {
printf(\是空串\\n\exit(0); chu->c=ch; if(head==NULL) {
head=chu;
} else
rear->next=chu; rear=chu;
ch=getchar(); }
if(rear!=NULL)
rear->next=NULL;
return head;
金陵科技学院实验报告
}
} { }
while(p->next!=NULL) { }
if(p->next==NULL)
p->next=s2; if(p->c==x)
break;
printf(\是空串\\n\exit(0); if(s2==NULL)
p=p->next;
else { }
q=s2;
while(q->next!=NULL)
q=q->next;
q->next=p->next; p->next=s2;
void display(chuan *chu) {
chuan *p;
p=chu; if(chu==NULL) {
金陵科技学院实验报告
}
}
printf(\空串\\n\exit(0);
printf(\while(p->next!=NULL) { }
p=p->next; printf(\
main() {
char x,c;
printf(\建立单链串t\\n\t=setup(t);
c=getchar();
printf(\建立单链串s\\n\s=setup(s);
c=getchar();
printf(\请输入要在什么字符后插入\\n\
x=getchar(); }
insert(t,s,x); display(t);
四、实验结果与分析(程序运行结果及其分析)
相关推荐: