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) ...
随机推荐
- Python Third Day-文件处理
文件处理 打开文件,得到文件句柄并赋值给一个变量f=open('a.txt','r',encoding='utf-8')#默认打开的方式为r指的是文本文件,全名为‘rt’#w文件方式指的是如果有a.t ...
- shell脚本中使用echo显示带颜色的内容
shell脚本中使用echo显示带颜色的内容,需要使用参数-e 格式如下: echo -e "\033[字背景颜色;文字颜色m字符串\033[0m" 例如: echo -e &qu ...
- 【HIHOCODER 1529】 不上升序列
描述 给定一个长度为 n 的非负整数序列 a[1..n]. 你每次可以花费 1 的代价给某个 a[i] 加1或者减1. 求最少需要多少代价能将这个序列变成一个不上升序列. 输入 第一行一个正整数 n. ...
- PAT Basic 1031
1031 查验身份证(15)(15 分) 一个合法的身份证号码由17位地区.日期编号和顺序编号加1位校验码组成.校验码的计算规则如下: 首先对前17位数字加权求和,权重分配为:{7,9,10,5,8, ...
- 几条sql语句(exists)
通常exists后的子查询是需要和外面的表建立关联关系的,如 select count(*) from a where exists (select 'x' from b where a.id = b ...
- js request学习
SP的内置对象在JSP页面中无须声明就可以直接使用,其内置对象常用的有Request,response,session,application,out,config,pageCOntext reque ...
- Java-字符转比较
实用的字符串比较方法 package com.tj; public class MyClass implements Cloneable { public static void main(Strin ...
- zoj 1760 Doubles
Doubles Time Limit: 2 Seconds Memory Limit: 65536 KB As part of an arithmetic competency progra ...
- Codeforces Round #438 by Sberbank and Barcelona Bootcamp (Div. 1 + Div. 2 combine
最近只想喊666,因为我是真得菜,大晚上到网吧打代码还是很不错的嘛 A. Bark to Unlock time limit per test 2 seconds memory limit per t ...
- 【bzoj4242】水壶 BFS+最小生成树+倍增LCA
题目描述 JOI君所居住的IOI市以一年四季都十分炎热著称. IOI市是一个被分成纵H*横W块区域的长方形,每个区域都是建筑物.原野.墙壁之一.建筑物的区域有P个,编号为1...P. JOI君只能进入 ...