Program:-
#include <bits/stdc++.h>
using namespace std;
struct number{
int a,b,c;
};
static bool comp(struct number aa, struct number ba){
return aa.a<ba.a;
}
int main() {
int n;
cin>>n;
struct number arr[n];
for(int i=0;i<n;i++)
{
int a,b,c;
cin>>a>>b>>c;
arr[i].a=a;
arr[i].b=b;
arr[i].c=c;
}
sort(arr,arr+n,comp);
for(int i=0;i<n;i++)
cout<<arr[i].a<<" "<<arr[i].b<<" "<<arr[i].c<<endl;
return 0;
}
#include <bits/stdc++.h>
using namespace std;
struct number{
int a,b,c;
};
static bool comp(struct number aa, struct number ba){
return aa.a<ba.a;
}
int main() {
int n;
cin>>n;
struct number arr[n];
for(int i=0;i<n;i++)
{
int a,b,c;
cin>>a>>b>>c;
arr[i].a=a;
arr[i].b=b;
arr[i].c=c;
}
sort(arr,arr+n,comp);
for(int i=0;i<n;i++)
cout<<arr[i].a<<" "<<arr[i].b<<" "<<arr[i].c<<endl;
return 0;
}
No comments:
Post a Comment