当前位置:网站首页>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;
}
边栏推荐
- Leetcode fizzbuzz C # answer
- 勾股数规律(任意三个数能够满足勾股定理需要满足的条件)
- Mysql database basic operation -ddl | dark horse programmer
- 矩阵翻转(数组模拟)
- Shell programming core technology "four"
- Oracle with as ora-00903: invalid table name multi report error
- 项目中遇到的线上数据迁移方案1---总体思路整理和技术梳理
- Shell 编程核心技术《三》
- Unity给自己的脚本添加类似编辑器扩展的功能案例ContextMenu的使用
- 生成XML元素
猜你喜欢
Stream stream
与二值化阈值处理相关的OpenCV函数、方法汇总,便于对比和拿来使用
The latest progress of Intel Integrated Optoelectronics Research promotes the progress of CO packaging optics and optical interconnection technology
Bi skills - permission axis
LeetCode第300场周赛(20220703)
Opencv functions and methods related to binary threshold processing are summarized for comparison and use
欧拉函数
大div中有多个div,这些div在同一行显示,溢出后产生滚动条而不换行
用实际例子详细探究OpenCV的轮廓绘制函数drawContours()
English grammar_ Noun - use
随机推荐
C#实现定义一套中间SQL可以跨库执行的SQL语句(案例详解)
数组中的第K个最大元素
如何使用Async-Awati异步任务处理代替BackgroundWorker?
The 15th youth informatics competition in Shushan District in 2019
Online text line fixed length fill tool
2014合肥市第三十一届青少年信息学奥林匹克竞赛(小学组)试题
在线SQL转Excel(xls/xlsx)工具
1008 Elevator(20 分)(PAT甲级)
PointNeXt:通过改进的模型训练和缩放策略审视PointNet++
Shell 编程核心技术《三》
Introduction to polyfit software
求2的n次方
prometheus安装
Unity编辑器扩展C#遍历文件夹以及子目录下的所有图片
2022CoCa: Contrastive Captioners are Image-Text Fountion Models
C# 使用StopWatch测量程序运行时间
2021 Hefei informatics competition primary school group
Upgrade the smart switch, how much is the difference between the "zero fire version" and "single fire" wiring methods?
876. 链表的中间结点
HDU 6440 2018中国大学生程序设计网络选拔赛