📄 单个节点的后插操作.txt
字号:
///////////////////////////////////////////////
// 作者:03031A班 李戬 //
// //
// 2003年 xx月 xx日 晚 //
///////////////////////////////////////////////
#include<iostream.h>
#include<stdlib.h>
#include<stdio.h>
#include<malloc.h>
typedef int datatype;
typedef struct node
{
datatype data;
struct node *next;
}linklist;
void main()
{
linklist *head,*s,*r;
int i,j,k,w;
cout<<"please enter a total number"<<endl;
cin>>i;
head=NULL;
for(j=1;j<=i;j++)
{
cout<<"please enter a number"<<endl;
cin>>k;
s=(linklist *)malloc(sizeof(linklist));
s->data=k;
if(head==NULL) head=s;
else
head->next=s;
head=s;
cout<<endl<<s->data<<endl;
}
r=(linklist *)malloc(sizeof(linklist));
cout<<"请输入要插入的数值:"<<endl;
cin>>w;
r->data=w;
r->next=s->next;
s->next=r;
cout<<endl<<s->next->data<<endl;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -