矩阵翻转---计蒜客

#include<iostream>
using namespace std;
typedef struct jz{
    int b[210];
};
int main()
{
    jz a[210];
	int m,n,t;
    cin>>m>>n>>t;
    for(int i=0;i<m;i++){
        for(int j=0;j<n;j++){
            cin>>a[i].b[j];
        }
    }
    if(t == 0){
		for(int i=0;i<m;i++){
			for(int j=n-1;j>=0;j--){
                cout<<a[i].b[j]<<" ";
			}
            cout<<endl;
        }
    }else{
        for(int i=m-1;i>=0;i--){
			for(int j=0;j<n;j++){
                cout<<a[i].b[j]<<" ";
			}
            cout<<endl;
        }
    }
    return 0;
}

思路:做个结构体处理起来就比二维数组避免了不少麻烦。

猜你喜欢

转载自blog.csdn.net/qq_37807889/article/details/84942590