当前位置:网站首页>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;
}
边栏推荐
- Shell programming core technology "three"
- Unity adds a function case similar to editor extension to its script, the use of ContextMenu
- 2022CoCa: Contrastive Captioners are Image-Text Fountion Models
- The explain statement in MySQL queries whether SQL is indexed, and several types in extra collate and summarize
- PolyFit软件介绍
- 26. 删除有序数组中的重复项 C#解答
- 1009 Product of Polynomials(25 分)(PAT甲级)
- 牛客小白月赛7 E Applese的超能力
- Unity editor extends C to traverse all pictures in folders and subdirectories
- Several methods of online database migration
猜你喜欢
Introduction to polyfit software
Hough transform Hough transform principle
Comment utiliser async awati asynchrone Task Handling au lieu de backgroundworker?
Pytorch学习(四)
There are multiple divs in the large div, which are displayed on the same line. After overflow, scroll bars are generated without line breaks
92.(cesium篇)cesium楼栋分层
PolyFit软件介绍
牛客小白月赛7 谁是神箭手
Summary and sorting of 8 pits of redis distributed lock
The latest progress of Intel Integrated Optoelectronics Research promotes the progress of CO packaging optics and optical interconnection technology
随机推荐
1009 Product of Polynomials(25 分)(PAT甲级)
页面元素垂直水平居中、实现已知或者未知宽度的垂直水平居中。
Introduction to polyfit software
1007 Maximum Subsequence Sum(25 分)(PAT甲级)
Allure of pytest visual test report
明明的随机数
Comment utiliser async awati asynchrone Task Handling au lieu de backgroundworker?
Hough transform Hough transform principle
Pointnet/Pointnet++点云数据集处理并训练
测试工程师如何“攻城”(上)
HDU 1097 A hard puzzle
Mysql database basic operation -ddl | dark horse programmer
长城证券开户安全吗 买股票怎么开户
2019年蜀山区第十五届青少年信息学竞赛
1011 World Cup Betting (20 分)(PAT甲级)
偏移量函数及开窗函数
Shell programming core technology "three"
The 15th youth informatics competition in Shushan District in 2019
Shell programming core technology II
redis分布式锁的8大坑总结梳理