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. web开发框架Flask学习一

    flask框架 用Python做Web开发的三大框架特点 Django 主要特点是大而全,集成了很多的组件,例如:Admin Form Model等,不管你用不用的到,他都会为 你提供,通常用于大型W ...

  2. 快速入门Numpy

    教你十分钟学会使用numpy. 简单介绍一下numpy的话,这就是一个基于多维数组的python科学计算的核心库. 基本信息 # 一般用np作为numpy的缩写 import numpy as np ...

  3. 【Oracle】使用dblink+minus方式迁移数据

    一.需求说明 1.数据库a104的表syssde.a4_syssde_department中有1000条数据: 2.数据库a230的表syssde.a4_syssde_department中有800条 ...

  4. 面试准备——rpc面试题

    https://www.jianshu.com/p/28e48e5f9c73 1 什么是 RPC ? RPC (Remote Procedure Call)即远程过程调用,是分布式系统常见的一种通信方 ...

  5. sequence有关问题

    sequence问题比如主键是 1,3,5,7,9,11 中间跳号了...用什么方法可以把主键重新排列为 1,2,3,4,5 ------解决方案--------------------update ...

  6. springboot集成redis操作

    使用HashOperations操作redis----https://www.cnblogs.com/shiguotao-com/p/10560458.html 使用HashOperations操作r ...

  7. Decorator(装饰器模式)

    装饰器模式允许我们根据运行时不同的情景动态地为某个对象调用前后添加不同的行为动作. <?php class HtmlTemplate { // any parent class methods ...

  8. Visual Studio 2013 滚动条实现代码缩略图

    启动Visual studio 2013,打开工具->选项   在搜索选项输入,滚动条,英文版大概输入Scroll bar or Scroll 或者:文本编辑器->所有语言->滚动条 ...

  9. POJ-3352 Road Construction,tarjan缩点求边双连通!

    Road Construction 本来不想做这个题,下午总结的时候发现自己花了一周的时间学连通图却连什么是边双连通不清楚,于是百度了一下相关内容,原来就是一个点到另一个至少有两条不同的路. 题意:给 ...

  10. 13-数组的API方法遍历

    <!DOCTYPE html> <html> <head lang="en"> <meta charset="UTF-8&quo ...