#include <iostream> using namespace std; int main(int argc, const char * argv[]) { int m, n, t, a[900][900], i, j; cin>>m>>n>>t;//m、n作为二维数组a的下标 //t为0时左右翻转,t为1时上下翻转 for(i = 0; i < m; i++)//嵌套循环,输入(m * n)个数 { for(j = 0; j < n; j++) { cin>>a[i][j]; } } if(t == 1)//t = 1,上下翻转 { for(i = m - 1; i >= 0; i--) { for(j = 0; j < n; j++) { cout<<a[i][j]<<" "; } cout<<"\n"; } } else if(t == 0)//t = 0,左右翻转 { for(i = 0; i < m; i++) { for(j = n - 1; j >= 0; j--) { cout<<a[i][j]<<" "; } cout<<"\n"; } } else //t != (0||1)的情况输入一个提示 { cout<<"The number of t = "<<t<<" is't 1 or 0!"<<endl; } return 0; }
二维数组翻转
最新推荐文章于 2024-10-07 14:44:39 发布