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 表示:90度,顺时针,翻转4个数  1 3 表示:90度,顺时针,翻转9个数  2 2 表示:90度,逆时针,翻转4个数  2 3 表示:90度,逆时针,翻转9个数 

输入描述:

输入有多组数据。
每组输入一个5 * 5的数组,然后输入一行,这一行有四个数,前两个代表操作类型,后两个数x y代表需操作数据为以x y为左上角的那几个数据。

输出描述:

输出翻转后的数组。
示例1

输入

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)的更多相关文章

  1. BUPT复试专题—找最小数(2010)

    https://www.nowcoder.com/practice/ba91786c4759403992896d859e87a6cd?tpId=67&tqId=29645&rp=0&a ...

  2. BUPT复试专题—比较奇偶数(2010)

    https://www.nowcoder.com/practice/188472f474d5421cb8218b8ad561023b?tpId=67&tqId=29636&rp=0&a ...

  3. BUPT复试专题—哈夫曼树(2010)

    https://www.nowcoder.com/practice/162753046d5f47c7aac01a5b2fcda155?tpId=67&tqId=29635&tPage= ...

  4. BUPT复试专题—串查找(?)

    https://www.nowcoder.com/practice/a988eda518f242c29009f8620f654ede?tpId=67&tqId=29642&rp=0&a ...

  5. BUPT复试专题—解析表达式(2015)

    题目描述 输入一个字符串形式的表达式,该表达式中包括整数,四则运算符(+.-.*./),括号,三角函数(sin(x).cos(x).tan(x)),底数函数(lg(x).ln(x)),计算该表达式的值 ...

  6. BUPT复试专题—字符串转换(2013计院)

    题目描述 我们将仅由若干个同一小写字母构成的字符串称之为简单串,例如"aaaa"是一个简单串,而"abcd"则不是简单串.现在给你一个仅由小写字母组成的字符串, ...

  7. BUPT复试专题—统计时间间隔(2013计院)

    题目描述 给出两个时间(24小时制),求第一个时间至少要经过多久才能到达第二个时间.给出的时间一定满足的形式,其中x和y分别代表小时和分钟.0≤x<24,0≤y<60. 输入格式 第一行为 ...

  8. BUPT复试专题—最值问题(2013计院)

    题目描述 给出N个数,求出这N个数中最大值和次大值.注意这里的次大值必须严格小于最大值.输入保证N个数中至少存在两个不同的数. 输入格式 第一行为测试数据的组数T(T≤20).请注意,任意两组测试数据 ...

  9. BUPT复试专题—数据库检索(2014软院)

    题目描述 在数据库的操作过程中,我们进场会遇到检索操作.这个题目的任务是完成一些特定格式的检索,并输出符合条件的数据库中的所有结果. 我们现在有一个数据库,维护了学生的姓名(Name),性别(Sex) ...

随机推荐

  1. mysql:having 用法

    顺序:where -> group by -> min -> order by -> limit 在select语句中使用having 子句来指定一组行或聚合的过滤条件 hav ...

  2. JS原生增删,判断class是否存在方法

    function hasClass(obj, cls) { if (obj.className) { return obj.className.match(new RegExp('(\\s|^)' + ...

  3. 【php】 php能做什么

    来源:php官方文档 网站和 web 应用程序(服务器端脚本) 命令行脚本 桌面(GUI)应用程序 相信大多数人都不知道第三种,用php竟然可以写GUI,当然是基于PHP-GTK扩展写的

  4. Python9-迭代器-生成器-day13

    迭代器# print('__iter__' in dir(int))# print('__iter__' in dir(list))# print('__iter__' in dir(dict))# ...

  5. linux-命令学习-1

    1. cat命令 http://blog.csdn.net/jackalfly/article/details/7556848 cat主要有三大功能:1.一次显示整个文件.$ cat   filena ...

  6. PAT Basic 1019

    1019 数字黑洞 给定任一个各位数字不完全相同的4位正整数,如果我们先把4个数字按非递增排序,再按非递减排序,然后用第1个数字减第2个数字,将得到一个新的数字.一直重复这样做,我们很快会停在有“数字 ...

  7. Django之url上的include,URL命名和反向解析,命名空间

    include其他的URLconfs   #At any point, your urlpatterns can “include” other URLconf modules. This #esse ...

  8. 【01】markdown特殊说明

    [01]说明 Markdown 的目标是实现「易读易写」. 可读性,无论如何,都是最重要的.一份使用 Markdown 格式撰写的文件应该可以直接以纯文本发布,并且看起来不会像是由许多标签或是格式指令 ...

  9. 图论trainning-part-1 A. 最短路

    A. 最短路 Time Limit: 1000ms Memory Limit: 32768KB 64-bit integer IO format: %I64d      Java class name ...

  10. PHP中file_put_contents追加和换行的实现方法

    在PHP的一些应用中需要写日志或者记录一些信息,这样的话.可以使用fopen(),fwrite()以及 fclose()这些进行操作.也可以简单的使用file_get_contents()和file_ ...