POJ 3752 字母旋转游戏
#include<iostream>
#include<iomanip>
using namespace std; void MATRIX(int** arr,int row,int col)//row为数组行,col为数组的列
{
int count=;
int x,y,min;
(row>col)? min=col : min=row;
if(arr==NULL||row<=||col<=) return;
for(int round=;round<min/;++round)
{
x=round;
for(y=round;y<col-round;y++)
{arr[x][y]=count++;} y=col-round-;
for(x=round+;x<row-round-;x++)
{arr[x][y]=count++;} x=row-round-;
for(y=col-round-;y>=round;y--)
{arr[x][y]=count++;} y=round;
for(x=row-round--;x>round;x--)
{arr[x][y]=count++;}
}
if(row==col&&row%==){arr[row/][col/]=count;}
if(min==row&&col!=row&&row%==)
{
for(y=min/;y<col-min/;y++)
arr[min/][y]=count++;
}
if(min==col&&col!=row&&col%==)
{for(x=min/;x<row-min/;x++)
arr[x][min/]=count++;
}
for(x=;x<row;x++)
for(y=;y<col;y++)
{ cout<<setw()<<char(arr[x][y]%+'A');
if(y==col-)
cout<<endl;
} } void main()
{
int **arr;
int col,row,i;
cin>>row>>col;
arr=new int*[row];//申请内存
for(i=;i!=row;++i)
{arr[i]= new int[col];}
MATRIX(arr,row,col);
for(i=;i!=row;++i)//释放内存
{delete [] arr[i];}
delete [] arr;
}
POJ 3752 字母旋转游戏的更多相关文章
- POJ.1067 取石子游戏 (博弈论 威佐夫博弈)
POJ.1067 取石子游戏 (博弈论 威佐夫博弈) 题意分析 简单的威佐夫博弈 博弈论快速入门 代码总览 #include <cstdio> #include <cmath> ...
- POJ 3752
http://poj.org/problem?id=3752 这是一道我觉得还蛮有意思的题目,不难,是个水题,但我也TLE了几次,感到很奇怪,这么简单的循环还TLE,最后一想,肯定是有几个例子我是没有 ...
- poj 1067 取石子游戏( 威佐夫博奕)
题目:http://poj.org/problem?id=1067 题意:有两堆石子,数量任意,可以不同.游戏开始由两个人轮流取石子.游戏规定,每次有两种不同的取法,一是可以在任意的一堆中取走任意多的 ...
- poj 1067 取石子游戏 (威佐夫博弈)
取石子游戏 http://poj.org/problem?id=1067 Time Limit: 1000MS Memory Limit: 10000K Description 有两堆 ...
- 打字母的游戏&Java入门
目标: 在一个窗体上随机掉落字母,通过键盘输入,敲对后消除并且累计积分,否则扣除一定积分. 具体内容: 画一个窗体——>产生随机字母——>接受键盘输入——>显示分数 代码: pack ...
- Java算法试题--猜字母/杀人游戏
题目例如以下: 把abcd-s共19个字母组成的序列反复拼接106次,得到长度为2014的串. 接下来删除第1个字母(即开头的字母a).以及第3个,第5个等全部奇数位置的字母. 得到的新串再进行删除奇 ...
- [原博客] POJ 1067 取石子游戏
题目链接有两堆石子,数量任意,可以不同.游戏开始由两个人轮流取石子.游戏规定,每次有两种不同的取法,一是可以在任意的一堆中取走任意多的石子:二是可以在两堆中同时取走相同数量的石子.最后把石子全部取完者 ...
- UVA_Rotation Game<旋转游戏> UVA 1343
The rotation game uses a # shaped board, which can hold 24 pieces of square blocks (see Fig.1). The ...
- 用OO方式写键盘字母小游戏
<html> <head> <title>0.0</title> <script> window.onload=functi ...
随机推荐
- ORACLE创建用户,建表空间,授予权限
1.创建用户表空间 CREATE TABLESPACE my_tsLOGGINGDATAFILE 'D:\app\win7\oradata\orcl\my_ts.dbf' SIZE 10M AUTOE ...
- ZOJ 3778 C - Talented Chef 水题
LINK:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3778 题意:有n道菜,每道菜需要\(a_i\)道工序,有m个锅可 ...
- Codeforces Round #191 (Div. 2) B. Hungry Sequence(素数筛选法)
. Hungry Sequence time limit per test 1 second memory limit per test 256 megabytes input standard in ...
- Eng1—English daily notes
English daily notes 2015年 4月 Phrases As a side note 作为附注,顺便说句题外话,和by the way意思相近,例句 As a side note, ...
- 【BZOJ4552】【HEOI2016】排序 [二分答案][线段树]
排序 Time Limit: 60 Sec Memory Limit: 256 MB[Submit][Status][Discuss] Description 在2016年,佳媛姐姐喜欢上了数字序列 ...
- 【BZOJ】1875: [SDOI2009]HH去散步 矩阵快速幂
[题意]给定n个点m边的无向图,求A到B恰好经过t条边的路径数,路径须满足每条边都和前一条边不同.n<=20,m<=60,t<=2^30. [算法]矩阵快速幂 [题解]将图的邻接矩阵 ...
- 从ZoomEye API 到 Weblogic 弱口令扫描
参考资料: ZoomEye API: https://www.zoomeye.org/api/doc Weblogic-Weakpassword-Scnner: https://github.com/ ...
- 设计模式之Composite
设计模式总共有23种模式这仅仅是为了一个目的:解耦+解耦+解耦...(高内聚低耦合满足开闭原则) Composite定义? 将对象以树形结构组织起来,以达成“部分-整体” 的层次结构. 想到Compo ...
- weblogic 包里面有中文文件名 会报错
目前:没有解决,只要有中文启动就报错 http://bbs.csdn.net/topics/10055670 http://www.2cto.com/os/201406/311394.html
- C语言回调函数总结
/* Main program ---calls--> Library function ---calls--> Callback funtion */ #include <stdi ...