样例:
input:
2 2 2
0 0 1
1 0 2
output:
0 0 1
0 1 2
思路:
转置矩阵知道的话还是很方便的,在输入的时候直接x和y换个位置,然后排序就好
参考代码:
#include <cstdio>
#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;
const int maxn=11111111;
int maxx=-0x3f3f3f3f;
int m,n,c;
struct num
{
int x,y;int val;bool operator<(const num &b){
if(x==b.x) return y<b.y;else return x<b.x;}
}a[maxn];
int main()
{
cin>>m>>n>>c;for(int i=1;i<=c;i++) cin>>a[i].y>>a[i].x>>a[i].val;sort(a+1,a+c+1);for(int i=1;i<=c;i++) cout<<a[i].x<<" "<<a[i].y<<" "<<a[i].val<<endl;return 0;
}