当前位置:网站首页>Matrix flip (array simulation)
Matrix flip (array simulation)
2022-07-04 19:36:00 【Acacia moon tower】
problem
Xiaomeng is currently working on an application for flipping pictures , You may also know , The picture is actually made up of dots . therefore , Xiaomeng wants to make a program that can flip the matrix first , To solve the core of his problem .
Input format
The first line of input includes integers separated by spaces M,N,T(0 < N,M < 200)M,N,T(0<N,M<200),TT The value of is 00 or 11. among MM and NN Respectively represent the number of rows and columns of the matrix to be processed ,TT by 00 Hour means turning left and right , by 11 Hour means to flip up and down .
After that MM That's ok , Each line includes NN It's an integer , Input the data of each row of the matrix in turn .
Output format
The output includes MM That's ok NN Column , Each number is separated by a space , There is a space at the end of each line , It represents the matrix after turning as required .
The sample input
4 4 1 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6
Sample output
3 4 5 6 9 0 1 2 5 6 7 8 1 2 3 4
Directly simulate with array .
#include <iostream>
#include <cstdio>
using namespace std;
const int MAXN = 210;
int mp[MAXN][MAXN];
int main() {
int m, n, t;
scanf("%d %d %d", &m, &n, &t);
for(int i = 0; i < m; i++) {
for(int j = 0; j < n; j++) {
scanf("%d", &mp[i][j]);
}
}
if(t == 1) {
for(int i = m - 1; i >= 0; i--) {
for(int j = 0; j < n; j++) {
printf("%d ", mp[i][j]);
}
printf("\n");
}
} else {
for(int i = 0; i < m; i++) {
for(int j = n - 1; j >= 0; j--) {
printf("%d ", mp[i][j]);
}
printf("\n");
}
}
return 0;
}
边栏推荐
- Go microservice (II) - detailed introduction to protobuf
- Explore the contour drawing function drawcontours() of OpenCV in detail with practical examples
- The page element is vertically and horizontally centered, realizing the vertical and horizontal centering of known or unknown width.
- C # implementation defines a set of SQL statements that can be executed across databases in the middle of SQL (detailed explanation of the case)
- Master the use of auto analyze in data warehouse
- 876. Intermediate node of linked list
- QT realizes interface sliding switching effect
- 在线SQL转Excel(xls/xlsx)工具
- Qt实现界面滑动切换效果
- 1008 Elevator(20 分)(PAT甲级)
猜你喜欢
随机推荐
How test engineers "attack the city" (Part 2)
函数式接口
Unity给自己的脚本添加类似编辑器扩展的功能案例ContextMenu的使用
Allure of pytest visual test report
联想首次详解绿色智城数字孪生平台 破解城市双碳升级难点
明明的随机数
Is it safe to open an account at Great Wall Securities? How to open an account when buying stocks
矩阵翻转(数组模拟)
Use canal and rocketmq to listen to MySQL binlog logs
Oracle with as ora-00903: invalid table name multi report error
PointNeXt:通过改进的模型训练和缩放策略审视PointNet++
Safer, smarter and more refined, Chang'an Lumin Wanmei Hongguang Mini EV?
Leetcode ransom letter C # answer
1006 Sign In and Sign Out(25 分)(PAT甲级)
在线文本行固定长度填充工具
欧拉函数
1672. 最富有客户的资产总量
26. Delete the duplicate item C solution in the ordered array
Don't just learn Oracle and MySQL!
长城证券开户安全吗 买股票怎么开户