题解

凌艺樽  •  5个月前


#include <bits/stdc++.h>
using namespace std;
const int N=2e5+10;
int n,m;
struct dp{
	int a[510];
}k[510];
bool swp(dp x,dp y)
{
	for(int i=1;i<=m;i++)
	{
		if(x.a[i]<y.a[i])
		{
			return 1;
		}
		else if(x.a[i]>y.a[i])
		{
			return 0;
		}
	}
}
int main()
{
	cin>>n>>m;
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=m;j++)
		{
			cin>>k[i].a[j];
		}
	}
	sort(k+1,k+n+1,swp);
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=m;j++)
		{
			cout<<k[i].a[j]<<" ";
		}
		cout<<endl;
	}
	return 0;
}

struct轻松解决


评论: