View Code of Problem 83

#include <iostream>
#include <cstdio>
using namespace std;
struct Stu{
    int a,b;
}stu[999];
bool cmp(Stu p,Stu q){
    return p.a<q.a;
}
int main(){
    int n,m;
    cin>>n>>m;
    for(int i=0;i<n+m;i++){
        cin>>stu[i].a>>stu[i].b;
    }
    sort(stu,stu+n+m,cmp);
    for(int i=0;i<n+m;i++)
        cout<<stu[i].a<<" "<<stu[i].b<<endl;
    return 0;
}


/*
Main.cc: In function 'int main()':
Main.cc:16:5: error: 'sort' was not declared in this scope
     sort(stu,stu+n+m,cmp);
     ^~~~
Main.cc:16:5: note: suggested alternative: 'qsort'
     sort(stu,stu+n+m,cmp);
     ^~~~
     qsort
*/

Double click to view unformatted code.


Back to problem 83