?? 5-3.c
字號:
#include <stdio.h>
#define N 10
typedef char datatype;
typedef struct node{
datatype data;
struct node *next;
} listnode;
typedef listnode *linklist;
listnode *p;
linklist creater()
{
char ch;
linklist head;
listnode *p,*r;
head=NULL;
r=NULL;/*r為尾指針*/
while((ch=getchar())!='\n'){
p=(listnode *)malloc(sizeof(listnode));
p->data=ch;
if(head=NULL)
head=p;/*head 指向第一個插入結點*/
else
r->next=p;/*插入到鏈表尾部*/
r=p;/*r指向最新結點,即最后結點*/
}
if (r!=NULL)
r->next=NULL;/*鏈表尾部結點的后繼指針指定為空*/
return(head);
}
main()
{
linklist newlist=creater();
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -