文章
5
粉丝
79
获赞
0
访问
3.0k
C语言 边输入一个数据边进行链表插入 了解一下
#include<stdio.h>
typedef struct Node{
int num;
struct Node *Next;
}node;
int main(){
node *head,*s,*ptr;
head = (node *)malloc(sizeof(node));
head -> Next = NULL;
ptr = (node *) malloc(sizeof(node));
int i =5,x;
while(i--){
scanf("%d",&x);
s = (node *) malloc(sizeof (node));
s -> num = x;
ptr = head;
if(ptr->Next == NULL){
ptr -> Next = s;
s -> Next = NULL;
}else{
while(ptr->Next != NULL){
if(ptr->Next->num > x){
&...
登录后发布评论
暂无评论,来抢沙发