花落


私信TA

用户名:aaa888ii

访问量:24045

签 名:

我胡汉三又回来了!

等  级
排  名 350
经  验 5128
参赛次数 3
文章发表 41
年  龄 18
在职情况 学生
学  校 东莞理工学院
专  业 软件工程

  自我简介:

喵喵喵?

解题思路:





注意事项:





参考代码

#include<stdio.h>
#include<stdlib.h>
#include<ctype.h>
#include<string.h>
#define Change(x,y){int t;t =x;x=y;y=t;}

 typedef struct list{
	int xuehao;
	int grade;
	struct list *next;
}node,*Node;


 Node creat (int );
 Node sort (Node ,Node);
int main()
{
	int n,m;
	Node head_a,head_b,head;
	scanf("%d%d",&n,&m);
	head_a = creat(n);
	head_b = creat(m);
	head = sort(head_a,head_b);
	while(head)
	{
		Node q;
		q = head;
		printf("%d %d\n",q->xuehao,q->grade);
		head= head->next;

	}
	return 0;

}

Node creat(int n)
{
	int i;
	Node first,second;
	Node head;
	head = (Node)malloc(sizeof(node));
	head->next = NULL;
	first = head;
    
	
	
	for(i=0;i<n;i++)
	{
		second = (Node)malloc(sizeof(node));
		second->next = NULL;
		scanf("%d%d",&(*second).xuehao,&(*second).grade);
		first->next = second;
		first = second;
		
	}


	return (head);
}
Node sort(Node a,Node b)
{
	Node head,q,p;
	int term=0;
	q = a;
	head = q;
	while(q->next)
	{
		q = q->next;
	}
	q->next = b->next;   //连接
	q = head->next;
	for(p=q;p!=NULL;p = p->next)
	{
		for(q=head->next;q->next!=NULL;q=q->next)
		{
			if(q->xuehao>q->next->xuehao) {Change(q->grade,q->next->grade);Change(q->xuehao,q->next->xuehao);}
		}
	}
	

	return head->next;
}

:

 

0.0分

0 人评分

看不懂代码?想转换其他语言的代码? 或者想问其他问题? 试试问问AI编程助手,随时响应你的问题:

编程语言转换万能编程问答  

代码解释器

代码纠错

SQL生成与解释

  评论区