BUPT复试专题—C翻转(2010)
https://www.nowcoder.com/practice/74bdb725421c4f80b4aca7266818baf0?tpId=67&tqId=29639&rp=0&ru=/kaoyan/retest/1005&qru=/ta/bupt-kaoyan/question-ranking
题目描述
输入描述:
输入有多组数据。
每组输入一个5 * 5的数组,然后输入一行,这一行有四个数,前两个代表操作类型,后两个数x y代表需操作数据为以x y为左上角的那几个数据。
输出描述:
输出翻转后的数组。
输入
1 2 3 4 5
6 7 8 9 10
11 12 13 14 15
16 17 18 19 20
21 22 23 24 25
1 3 1 1
输出
11 6 1 4 5
12 7 2 9 10
13 8 3 14 15
16 17 18 19 20
21 22 23 24 25 此题只有四种情况可以逐个来换序,如果更复杂再考虑其他关系
#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<string.h>
using namespace std;
int a[][];
void turn1(int x,int y)
{
int temp[][];
temp[][]=a[x+][y];temp[][]=a[x+][y];temp[][]=a[x+][y+];temp[][]=a[x+][y+];
temp[][]=a[x][y];temp[][]=a[x][y+];temp[][]=a[x+][y+];temp[][]=a[x+][y+];temp[][]=a[x][y+];
a[x][y+]=temp[][];a[x+][y+]=temp[][];a[x+][y]=temp[][];a[x+][y+]=temp[][];a[x+][y+]=temp[][];
a[x][y]=temp[][];a[x][y+]=temp[][];a[x+][y]=temp[][];a[x+][y+]=temp[][];
}
void turn2(int x,int y)
{
int temp[][];
temp[][]=a[x][y+];temp[][]=a[x+][y+];temp[][]=a[x][y+];temp[][]=a[x+][y+];
temp[][]=a[x+][y+];temp[][]=a[x+][y+];temp[][]=a[x][y];temp[][]=a[x+][y];temp[][]=a[x+][y];
a[x][y+]=temp[][];a[x+][y+]=temp[][];a[x+][y]=temp[][];a[x+][y+]=temp[][];a[x+][y+]=temp[][];
a[x][y]=temp[][];a[x][y+]=temp[][];a[x+][y]=temp[][];a[x+][y+]=temp[][];
}
void turn3(int x,int y)
{
int temp[][];
temp[][]=a[x+][y];temp[][]=a[x][y];temp[][]=a[x+][y+];temp[][]=a[x][y+];
a[x][y]=temp[][];a[x][y+]=temp[][];a[x+][y]=temp[][];a[x+][y+]=temp[][];
}
void turn4(int x,int y)
{
int temp[][];
temp[][]=a[x][y+];temp[][]=a[x+][y+];temp[][]=a[x][y];temp[][]=a[x+][y];
a[x][y]=temp[][];a[x][y+]=temp[][];a[x+][y]=temp[][];a[x+][y+]=temp[][];
}
int main()
{
while(scanf("%d %d %d %d %d",&a[][],&a[][],&a[][],&a[][],&a[][])!=EOF)
{
int num=, m,n,x,y;
while(num!=)
{
scanf("%d %d %d %d %d",&a[num][],&a[num][],&a[num][],&a[num][],&a[num][]);
num++;
}
scanf("%d %d %d %d",&m,&n,&x,&y);
if(n==&&m==)
{
turn1(x-,y-);
}
else if(n==&&m==)
{
turn2(x-,y-);
}
else if(n==&&m==)
{
turn3(x-,y-);
}
else if(n==&&m==)
{
turn4(x-,y-);
}
for(int i=; i<; i++)
{
for(int j=; j<; j++)
{
cout<<a[i][j];
if(j<)
cout<<" ";
}
cout<<endl;
}
}
return ;
}
BUPT复试专题—C翻转(2010)的更多相关文章
- BUPT复试专题—找最小数(2010)
https://www.nowcoder.com/practice/ba91786c4759403992896d859e87a6cd?tpId=67&tqId=29645&rp=0&a ...
- BUPT复试专题—比较奇偶数(2010)
https://www.nowcoder.com/practice/188472f474d5421cb8218b8ad561023b?tpId=67&tqId=29636&rp=0&a ...
- BUPT复试专题—哈夫曼树(2010)
https://www.nowcoder.com/practice/162753046d5f47c7aac01a5b2fcda155?tpId=67&tqId=29635&tPage= ...
- BUPT复试专题—串查找(?)
https://www.nowcoder.com/practice/a988eda518f242c29009f8620f654ede?tpId=67&tqId=29642&rp=0&a ...
- BUPT复试专题—解析表达式(2015)
题目描述 输入一个字符串形式的表达式,该表达式中包括整数,四则运算符(+.-.*./),括号,三角函数(sin(x).cos(x).tan(x)),底数函数(lg(x).ln(x)),计算该表达式的值 ...
- BUPT复试专题—字符串转换(2013计院)
题目描述 我们将仅由若干个同一小写字母构成的字符串称之为简单串,例如"aaaa"是一个简单串,而"abcd"则不是简单串.现在给你一个仅由小写字母组成的字符串, ...
- BUPT复试专题—统计时间间隔(2013计院)
题目描述 给出两个时间(24小时制),求第一个时间至少要经过多久才能到达第二个时间.给出的时间一定满足的形式,其中x和y分别代表小时和分钟.0≤x<24,0≤y<60. 输入格式 第一行为 ...
- BUPT复试专题—最值问题(2013计院)
题目描述 给出N个数,求出这N个数中最大值和次大值.注意这里的次大值必须严格小于最大值.输入保证N个数中至少存在两个不同的数. 输入格式 第一行为测试数据的组数T(T≤20).请注意,任意两组测试数据 ...
- BUPT复试专题—数据库检索(2014软院)
题目描述 在数据库的操作过程中,我们进场会遇到检索操作.这个题目的任务是完成一些特定格式的检索,并输出符合条件的数据库中的所有结果. 我们现在有一个数据库,维护了学生的姓名(Name),性别(Sex) ...
随机推荐
- (三)Python3 循环语句——while
while语句的一般形式: while 判断条件: 语句 同样需要注意冒号和缩进.另外,在 Python 中没有 do..while 循环. 以下实例使用了 while 来计算 1 到 100 的总和 ...
- python 学习总结4
数字类型及操作 一.整数类型 (1)python中的整数与数学中的概念是一致的,可以正也可以负,没有取值范围. pow(x,y)函数是计算x的y次幂,想计算多大就多大. (2)在整数类型中有四种进 ...
- UnicodeDecodeError: 'gbk' codec can't decode byte 0xae in position 167: illegal multibyte sequence
UnicodeDecodeError: 'gbk' codec can't decode byte 0xae in position 167: illegal multibyte sequence文件 ...
- 自学入门 Python 优质中文资源索引
所有资源基于 Python3 版本,全部中文内容,适用于 爬虫 / Web / 数据 方向,每个单元根据学习习惯从 书籍 / 文档 / 视频 中选择一类即可,建议任选一本书籍,然后配合文档类进行学习. ...
- IOS 自动布局-UIStackPanel和UIGridPanel(二)
在上一篇中我提到了如何使用stackpanel和gridpanel来实现自动布局.而在这一篇中我着重讲解下其中的原理. 在(UIPanel UIStackPanel UIGridPanel)中主 ...
- 【编程工具】Sublime Text3快捷键配置
我们在使用编译软件时,总是喜欢使用快捷键来方便我们的操作,但有些编译软件不支持快捷键的修改和设置,为了能够更加方便的使用 Sublime Text3,这里我介绍几个 Sublime Text3 设置快 ...
- POJ-1065 Wooden Sticks,排序+最长单减子序列!
Wooden Sticks 题意:有一台机器处理木材,最开始需要一分钟准备,如果后面处理的木材比前 ...
- Replication and Triggers
参考官网:https://dev.mysql.com/doc/refman/5.7/en/replication-features-triggers.html 需要了解复制和触发器关系的背景: 程序变 ...
- spring配置druid连接池和监控数据库访问性能
Druid连接池及监控在spring配置如下: <bean id="dataSource" class="com.alibaba.druid.pool.DruidD ...
- UITableView滑动动画+FPSLabel
主要使用了tableView的代理方法 行将要显示的时候 - (void)tableView:(UITableView *)tableView willDisplayCell:(UITableView ...