解题思路:
注意事项:
参考代码:
#include<iostream> using namespace std; typedef struct node{ int num; int s; struct node *next; }student; student *input(int n){//创建列表 student *head=new student; head->next=NULL; student *q=head; for(int i=0;i<n;i++){ student *p=new student; cin>>p->num; cin>>p->s; p->next=NULL; q->next=p; q=p; } return head; } student *f(student *head){//排序 student *p,*min,*q=head->next; while(q->next!=NULL){ p=q,min=q; while(p!=NULL){ if(p->num<min->num){ min=p; } p=p->next; } int t1,t2; t1=min->s;t2=min->num; min->s=q->s;min->num=q->num; q->s=t1;q->num=t2; q=q->next; } return head; } int main() { int n,m; cin>>n>>m; student *a=input(n); student *b=input(m); student *p1=a; while(p1->next!=NULL) p1=p1->next; student *p2=b->next; p1->next=p2; b->next=NULL; a=f(a); student *p=a->next; while(p!=NULL){ cout<<p->num<<" "<<p->s<<endl; p=p->next; } return 0; }
0.0分
0 人评分
蛇行矩阵 (C语言代码)浏览:753 |
printf基础练习2 (C语言代码)浏览:646 |
简单的a+b (C语言代码)浏览:419 |
2006年春浙江省计算机等级考试二级C 编程题(1) (C语言代码)浏览:669 |
矩形面积交 (C语言代码)浏览:1312 |
C语言程序设计教程(第三版)课后习题12.3 (C语言代码)浏览:548 |
矩阵的对角线之和 (C语言代码)浏览:1356 |
简单的事情 (C语言代码)浏览:638 |
C二级辅导-统计字符 (C语言代码)浏览:647 |
排序算法(选择,插入,冒泡)浏览:775 |