当前位置:网站首页>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;
}
边栏推荐
- socket编程demo二
- 1672. 最富有客户的资产总量
- Several methods of online database migration
- C# 使用StopWatch测量程序运行时间
- 92.(cesium篇)cesium楼栋分层
- The kth largest element in the array
- Pytorch学习(四)
- Some thoughts on whether the judgment point is located in the contour
- Unity adds a function case similar to editor extension to its script, the use of ContextMenu
- The latest progress of Intel Integrated Optoelectronics Research promotes the progress of CO packaging optics and optical interconnection technology
猜你喜欢
Comment utiliser async awati asynchrone Task Handling au lieu de backgroundworker?
SSRS筛选器的IN运算(即包含于)用法
Nebula importer data import practice
联想首次详解绿色智城数字孪生平台 破解城市双碳升级难点
Explore the contour drawing function drawcontours() of OpenCV in detail with practical examples
大div中有多个div,这些div在同一行显示,溢出后产生滚动条而不换行
Online sql to excel (xls/xlsx) tool
Opencv functions and methods related to binary threshold processing are summarized for comparison and use
Lenovo explains in detail the green smart city digital twin platform for the first time to solve the difficulties of urban dual carbon upgrading
Stream流
随机推荐
Explicit random number
Allure of pytest visual test report
Technologie de base de la programmation Shell IV
HDU 1097 A hard puzzle
Shell programming core technology "three"
FPGA时序约束分享01_四大步骤简述
Master the use of auto analyze in data warehouse
升级智能开关,“零火版”、“单火”接线方式差异有多大?
876. 链表的中间结点
1672. 最富有客户的资产总量
Educational Codeforces Round 22 E. Army Creation
Don't just learn Oracle and MySQL!
Double colon function operator and namespace explanation
26. 删除有序数组中的重复项 C#解答
添加命名空间声明
Is Guoyuan futures a regular platform? Is it safe to open an account in Guoyuan futures?
LeetCode FizzBuzz C#解答
SSRS筛选器的IN运算(即包含于)用法
Hough Transform 霍夫变换原理
Functional interface