解题思路:
注意事项:
参考代码
#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 人评分
母牛的故事 (C语言代码)浏览:551 |
数对 (C语言代码)浏览:702 |
2003年秋浙江省计算机等级考试二级C 编程题(1) (C语言代码)浏览:682 |
C语言程序设计教程(第三版)课后习题12.2 (C语言代码)浏览:765 |
良心推荐——>题解1049:C语言程序设计教程(第三版)课后习题11.1 (C语言描述——简单明了,时间复杂度低)浏览:1287 |
1005答案错误为什么浏览:1975 |
拆分位数 (C语言代码)浏览:444 |
C语言程序设计教程(第三版)课后习题1.5 (C语言代码)浏览:456 |
孤独的骑士 (C语言代码)浏览:1368 |
众数问题 (C语言代码)浏览:630 |