当前位置:网站首页>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;
}
边栏推荐
- . Net ORM framework hisql practice - Chapter 2 - using hisql to realize menu management (add, delete, modify and check)
- MySQL数据库基本操作-DDL | 黑马程序员
- There are multiple divs in the large div, which are displayed on the same line. After overflow, scroll bars are generated without line breaks
- OpenCV的二值化处理函数threshold()详解
- SSRS筛选器的IN运算(即包含于)用法
- YOLOv5s-ShuffleNetV2
- 大div中有多个div,这些div在同一行显示,溢出后产生滚动条而不换行
- 求2的n次方
- 2022CoCa: Contrastive Captioners are Image-Text Fountion Models
- Shell 编程核心技术《四》
猜你喜欢
The latest progress of Intel Integrated Optoelectronics Research promotes the progress of CO packaging optics and optical interconnection technology
联想首次详解绿色智城数字孪生平台 破解城市双碳升级难点
"Only one trip", active recommendation and exploration of community installation and maintenance tasks
在线文本行固定长度填充工具
node_ Exporter deployment
Oracle with as ORA-00903: invalid table name 多表报错
Several methods of online database migration
Safer, smarter and more refined, Chang'an Lumin Wanmei Hongguang Mini EV?
PointNeXt:通过改进的模型训练和缩放策略审视PointNet++
SSRS筛选器的IN运算(即包含于)用法
随机推荐
Stream流
基于NCF的多模块协同实例
. Net ORM framework hisql practice - Chapter 2 - using hisql to realize menu management (add, delete, modify and check)
欧拉函数
Unity adds a function case similar to editor extension to its script, the use of ContextMenu
Personal thoughts on Architecture Design (this article will be revised and updated continuously later)
Shell 编程核心技术《二》
FTP, SFTP file transfer
ftp、sftp文件传输
Add namespace declaration
Unity editor extends C to traverse all pictures in folders and subdirectories
1003 Emergency(25 分)(PAT甲级)
1672. 最富有客户的资产总量
26. Delete the duplicate item C solution in the ordered array
876. Intermediate node of linked list
在线SQL转Excel(xls/xlsx)工具
HDU 1097 A hard puzzle
Technologie de base de la programmation Shell IV
明明的随机数
Wireshark网络抓包