当前位置:网站首页>矩阵翻转(数组模拟)
矩阵翻转(数组模拟)
2022-07-04 17:59:00 【相思明月楼】
问题
晓萌最近在做一个翻转图片的应用,你可能也知道,图片其实是由一个个的点组成的。于是,晓萌想先做一个可以翻转矩阵的程序,来解决他问题的核心部分。
输入格式
输入第一行包括由空格分开的整数 M,N,T(0 < N,M < 200)M,N,T(0<N,M<200),TT 的值为 00 或 11。其中 MM 和 NN 分别表示待处理矩阵的行数与列数,TT 为 00 时表示左右翻转,为 11 时表示上下翻转。
之后的 MM 行,每行包括由空格分隔的 NN 个整数,依次为输入矩阵的每一行的数据。
输出格式
输出包括 MM 行 NN 列,每个数字之间用一个空格分隔,每一行行末均有一个空格,表示的是按照要求翻转后的矩阵。
样例输入
4 4 1 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6
样例输出
3 4 5 6 9 0 1 2 5 6 7 8 1 2 3 4
直接用数组模拟。
#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;
}
边栏推荐
- Nebula importer data import practice
- Nebula Importer 数据导入实践
- Don't just learn Oracle and MySQL!
- QT realizes interface sliding switching effect
- 安徽 中安在线文旅频道推出“跟着小编游安徽”系列融媒体产品
- Qt实现界面滑动切换效果
- Technologie de base de la programmation Shell IV
- 爬虫(6) - 网页数据解析(2) | BeautifulSoup4在爬虫中的使用
- Go microservice (II) - detailed introduction to protobuf
- Technology sharing | interface testing value and system
猜你喜欢

在线文本行固定长度填充工具

FPGA时序约束分享01_四大步骤简述

Hough transform Hough transform principle

性能优化之关键渲染路径

在线SQL转Excel(xls/xlsx)工具

Use canal and rocketmq to listen to MySQL binlog logs

Go microservice (II) - detailed introduction to protobuf

大div中有多个div,这些div在同一行显示,溢出后产生滚动条而不换行

【问题】druid报异常sql injection violation, part alway true condition not allow 解决方案

Comment utiliser async awati asynchrone Task Handling au lieu de backgroundworker?
随机推荐
用实际例子详细探究OpenCV的轮廓绘制函数drawContours()
[release] a tool for testing WebService and database connection - dbtest v1.0
Lm10 cosine wave homeopathic grid strategy
2022CoCa: Contrastive Captioners are Image-Text Fountion Models
Pointnet/Pointnet++点云数据集处理并训练
[uniapp] uniapp development app online Preview PDF file
26. 删除有序数组中的重复项 C#解答
php伪原创api对接方法
关于判断点是否位于轮廓内的一点思考
FTP, SFTP file transfer
The page element is vertically and horizontally centered, realizing the vertical and horizontal centering of known or unknown width.
The latest progress of Intel Integrated Optoelectronics Research promotes the progress of CO packaging optics and optical interconnection technology
Safer, smarter and more refined, Chang'an Lumin Wanmei Hongguang Mini EV?
ftp、sftp文件传输
Qt实现界面滑动切换效果
请教一下 flinksql中 除了数据统计结果是状态被保存 数据本身也是状态吗
Unity给自己的脚本添加类似编辑器扩展的功能案例ContextMenu的使用
1006 Sign In and Sign Out(25 分)(PAT甲级)
启牛开的证券账户安全吗?
From automation to digital twins, what can Tupo do?