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. Python可变与不可变类型及垃圾回收机制

    1. 可变与不可变类型 1.1  可变类型 在id不变的情况下,value可以改变,则称之为可变类型.列表.字典与集合是可变的. l1 = [,,,,] print(id(l1)) l1[] = #改 ...

  2. UIBarButtonSystemItem 样式

    使用时需要注意创建方式的区别: 01 typedef enum { 02     UIBarButtonSystemItemDone, 03     UIBarButtonSystemItemCanc ...

  3. React中css的使用

    网页的布局.颜色.形状等UI展示方式主要是由Css进行设置,在ReactJs中也是一样.ReactJs中的Css结构方式与传统的Web网页类似,但依然存在一些差异.ReactJs中Css文件本身的编写 ...

  4. vscode python code-runner 中文乱码解决

    https://www.cnblogs.com/zhaoshizi/p/9050768.html 这里我使用的是第二种方法

  5. 【02】xmind如何修改默认线条设置

    [02]xmind如何修改不同主题的默认线条设置 魔芋:每次都是曲线.更喜欢为直线.因为曲线的路线是不确定的,看起来就显示很凌乱. 用everything搜索defaultStyles.xml     ...

  6. [转]Mac屏幕录像转成gif

    http://note.axiaoxin.com/contents/mac-video2gif.html 屏幕录像 打开Quicktime Player -> 文件 -> 新建屏幕录像 - ...

  7. 【LeetCode】ZigZag Conversion(Z 字形变换)

    这道题是LeetCode里的第6道题. 题目要求: 将一个给定字符串根据给定的行数,以从上往下.从左到右进行 Z 字形排列. 比如输入字符串为 "LEETCODEISHIRING" ...

  8. 2017ACM/ICPC广西邀请赛-重现赛(感谢广西大学)

    上一场CF打到心态爆炸,这几天也没啥想干的 A Math Problem Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/3 ...

  9. hdu2084

    老题目了 #include <stdio.h> int main(){ ][]; int i,j,max; int c,n; scanf("%d",&c); w ...

  10. 机房合作(三):We are Team,We are Family

    导读:拖拖拉拉,机房的合作也算是接近了尾声了.在这个过程中,真心是感谢我的两个组员.这个机房合作,看似简单,但我的组员给我的帮助和感动,都是不可忽略的.记得刚开始的时候,我就说过:不怕猪一样的组长,咱 ...