1 Star 0 Fork 0

zhuoxue/代码学习的路途

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
lianbiao.c 759 Bytes
一键复制 编辑 原始数据 按行查看 历史
zhuoxue 提交于 2022-10-09 21:45 +08:00 . WEEK6
#include<stdio.h>
#include<stdlib.h>
struct node {
int data;
struct node *next;
};
int main(){
struct node *head, *p, *q, *t;
int i, n, a;
scanf("%d", &n);
head = NULL;
for(i = 1;i <= n;i ++){
scanf("%d", &a);
p = (struct node*)malloc(sizeof(struct node));
p -> data = a;
p -> next = NULL;
if(head == NULL){
head = p;
}
else{
q -> next = p;
}
q = p;
}
scanf("%d", &a);
t = head;
while(t != NULL){
if(t -> next == NULL || t -> next -> data > a){
p = (struct node*)malloc(sizeof(struct node*));
p -> data = a;
p -> next = t -> next;
t -> next = p;
break;
}
else{
t = t -> next;
}
}
t = head;
while(t != NULL){
printf("%d ", t -> data);
t = t -> next;
}
printf("\n");
return 0;
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/Joci-zhuoxue/the-way-of-code-learning.git
git@gitee.com:Joci-zhuoxue/the-way-of-code-learning.git
Joci-zhuoxue
the-way-of-code-learning
代码学习的路途
main

搜索帮助