View Code of Problem 83

#include<bits/stdc++.h>
using namespace std;
struct student{
	int id;
	int score;
};
int main(){
	int N,M;
	cin>>N>>M;
	struct student a[N],b[M],c[M+N];
	for(int i=0;i<N;i++){
		cin>>a[i].id;
		cin>>a[i].score;
		c[i]=a[i];
		
	}
	for(int i=0;i<M;i++){
		cin>>b[i].id;
		cin>>b[i].score;
		c[i+N]=b[i];
		
	}
	
	struct student temp;
	for(int i=0;i<N+M;i++){
		for(int j=0;j<N+M-i;j++){
			if(c[j].id>c[j+1].id){
				temp=c[j];
				c[j]=c[j+1];
				c[j+1]=temp;
			}
		}
	}
	for(int i=0;i<N+M;i++){
		cout<<c[i].id<<" "<<c[i].score<<"\n";
	}
	
	
	
	
}

Double click to view unformatted code.


Back to problem 83