?? 5-9.c
字號:
#include <stdio.h>
typedef char datatype;
typedef struct node{
datatype data;
struct node *next;
} listnode;
typedef listnode *linklist;
listnode *p;
linklist createlist(void)
{
char ch;
linklist head;
listnode *p;
head=NULL;//初始化為空
ch=getchar( );
while (ch!='\n'){
p=(listnode*)malloc(sizeof(listnode));/*分配空間*/
p->data=ch;/*數據域賦值*/
p->next=head;/*指定后繼指針*/
head=p;/*head指針指定到新插入的結點上*/
ch=getchar( );
}
return (head);
}
linklist concatenate(linklist list1,linklist list2)
{
listnode *temp;
if (list1==NULL)
return list2;
else {
if (list2!=NULL) {
for ( temp =list1; temp->next; temp = temp->next )
; /*遍歷到list1的末尾*/
temp->next=list2;/*將list2鏈接到list1末尾*/
}
}
return list1;
}
main()
{
linklist list1,list2,list3;
list1=createlist();
list2=createlist();
list3=concatenate(list1,list2);
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -