解题思路:
注意事项:
参考代码:
#include<stdio.h>
#include<stdlib.h>
int main()
{
typedef struct Link_List {
int num;
int mark;
struct Linke_List* next;
}Node;
Node* headera = malloc(sizeof(Node));
Node* headerb = malloc(sizeof(Node));
int a, b, i, number, grade;
if (headera != NULL && headerb != NULL) {
headera->next = NULL;
headerb->next = NULL;
}
Node* taila = headera;
Node* tailb = headerb;
scanf("%d", &a);
scanf("%d", &b);
for (i = 1; i <= a; i++)
{
Node* nodea = malloc(sizeof(Node));
scanf("%d", &number);
scanf("%d", &grade);
if (nodea != NULL)
{
nodea->num = number;
nodea->mark = grade;
nodea->next = NULL;
}
taila->next = nodea;
taila = nodea;
}
for (i = 1; i <= b; i++)
{
Node* nodeb = malloc(sizeof(Node));
scanf("%d", &number);
scanf("%d", &grade);
if (nodeb != NULL)
{
nodeb->num = number;
nodeb->mark = grade;
nodeb->next = NULL;
}
if (taila != NULL) {
tailb->next = nodeb;
tailb = nodeb;
}
}
if (taila != NULL) {
taila->next = headerb->next;
}
Node* Current = headera->next;
if (Current != NULL)
{
Node* Next = Current->next;
}
int t;
while (Current != NULL)
{
Node* Next = Current->next;
while(Next != NULL)
{
if (Current->num > Next->num)
{
t = Current->num;
Current->num = Next->num;
Next->num = t;
t = Current->mark;
Current->mark = Next->mark;
Next->mark = t;
}
Next = Next->next;
}
Current = Current->next;
}
Current = headera->next;
while (Current != NULL)
{
printf("%d ", Current->num);
printf("%d\n", Current->mark);
Current = Current->next;
}
return 0;
}
0.0分
0 人评分
C语言网提供由在职研发工程师或ACM蓝桥杯竞赛优秀选手录制的视频教程,并配有习题和答疑,点击了解:
一点编程也不会写的:零基础C语言学练课程
解决困扰你多年的C语言疑难杂症特性的C语言进阶课程
从零到写出一个爬虫的Python编程课程
只会语法写不出代码?手把手带你写100个编程真题的编程百练课程
信息学奥赛或C++选手的 必学C++课程
蓝桥杯ACM、信息学奥赛的必学课程:算法竞赛课入门课程
手把手讲解近五年真题的蓝桥杯辅导课程
发表评论 取消回复