当前位置:网站首页>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;
}
边栏推荐
- FTP, SFTP file transfer
- The kth largest element in the array
- To sort out messy header files, I use include what you use
- . Net ORM framework hisql practice - Chapter 2 - using hisql to realize menu management (add, delete, modify and check)
- Shell 编程核心技术《四》
- "Only one trip", active recommendation and exploration of community installation and maintenance tasks
- 1008 Elevator(20 分)(PAT甲级)
- 明明的随机数
- 2014合肥市第三十一届青少年信息学奥林匹克竞赛(小学组)试题
- Wechat reading notes of "work, consumerism and the new poor"
猜你喜欢

用实际例子详细探究OpenCV的轮廓绘制函数drawContours()

Use canal and rocketmq to listen to MySQL binlog logs

Introduction to polyfit software

Safer, smarter and more refined, Chang'an Lumin Wanmei Hongguang Mini EV?

FPGA timing constraint sharing 01_ Brief description of the four steps

Pointnet/Pointnet++点云数据集处理并训练

Go microservice (II) - detailed introduction to protobuf

Online sql to excel (xls/xlsx) tool

LeetCode第300场周赛(20220703)

PolyFit软件介绍
随机推荐
How to use async Awati asynchronous task processing instead of backgroundworker?
一文掌握数仓中auto analyze的使用
长城证券开户安全吗 买股票怎么开户
添加命名空间声明
牛客小白月赛7 F题
Add namespace declaration
PolyFit软件介绍
MySQL数据库基本操作-DDL | 黑马程序员
In flinksql, in addition to data statistics, is the saved data itself a state
The CDC of sqlserver can read the data for the first time, but it can't read the data after adding, deleting and modifying. What's the reason
The 15th youth informatics competition in Shushan District in 2019
Wechat reading notes of "work, consumerism and the new poor"
在线文本行固定长度填充工具
Hough transform Hough transform principle
1011 World Cup Betting (20 分)(PAT甲级)
使用canal配合rocketmq监听mysql的binlog日志
“只跑一趟”,小区装维任务主动推荐探索
Guys, for help, I use MySQL CDC 2.2.1 (Flink 1.14.5) to write Kafka and set
Educational Codeforces Round 22 E. Army Creation
mysql中explain语句查询sql是否走索引,extra中的几种类型整理汇总