View Code of Problem 83

#include <iostream>
#include <cstdio>
using namespace std;
struct student{
    int a,b;
}stu[999];
int main(){
    int N , M , t=0,min1=0;
    cin>>N>>M;
    int min = 999;
    for(int i = 0 ; i < N+M ; i++){
        cin>>stu[i].a>>stu[i].b;
    }
    for(int i = 0 ; i < N+M ; i++){
        for(int j = i ; j < N+M ; j++){
        if(stu[j].a < min){
            min = stu[j].a;
            min1 = stu[j].b;
            t = j;
        }
        }
        stu[t] = stu[i];
        stu[i].a = min;
        stu[i].b = min1;
        min = 999;
    }
    for(int i = 0 ; i < N+M ; i++){
        cout<<stu[i].a<<" "<<stu[i].b<<endl;
    }
    return 0;
}

Double click to view unformatted code.


Back to problem 83