洛谷P4327 [COCI2006-2007#1] Okviri

目录

AC code


题目描述

“Peter Pan frames” are a way of decorating text in which every character is framed by a diamond shaped frame, with frames of neigbhouring characters interleaving. A Peter Pan frame for one letter looks like this ('X' is the letter we are framing):

..#..
.#.#.
#.X.#
.#.#.
..#..

However, such a framing would be somewhat dull so we'll frame every third letter using a “Wendyframe”. A Wendy frame looks like this:

..*..
.*.*.
*.X.*
.*.*.
..*..

When a Wendy frame interleaves with a Peter Pan frame, the Wendy frame (being much nicer) is put on top. For an example of the interleaving check the sample cases.

输入格式

The first and only line of input will contain at most 15 capital letters of the English alphabet.

输出格式

Output the word written using Peter Pan and Wendy frames on 5 lines.

题意翻译

“彼得·潘框架”是一种装饰文字,每一个字母都是由一个菱形框架。一个彼得·潘框架看起来像这样 (x是字母,#是框架):

..#..
.#.#.
#.X.#
.#.#.
..#..

然而,只是一个框架会有些沉闷,所以我们每遇到三个字母会把第三个字母用温迪框架把它框起来。温迪框架看起来像这样:

..*..
.*.*.
*.X.*
.*.*.
..*..

当温迪和彼得·潘的框架重叠时,温迪框架覆盖在上面。 (见样例3和4)

输入格式: 一行包含至多15个英文字母的大写字母。

输出格式: 输出使用彼得·潘和温迪框架写成的5行文字。


输入输出格式


输入格式

The first and only line of input will contain at most 15 capital letters of the English alphabet.

输出格式

Output the word written using Peter Pan and Wendy frames on 5 lines.

输入输出样例

输入

ABCD

输出

..#...#...*...#..
.#.#.#.#.*.*.#.#.
#.A.#.B.*.C.*.D.#
.#.#.#.#.*.*.#.#.
..#...#...*...#..

AC code

#include <bits/stdc++.h>//万能头,好东西
using namespace std;
int len,lena,ll=3,aa;//ll为第一个字母的初始位置
char a[20],b[1000][100],c;
int main(){
	cin>>a;//输入初始字符串
	len=strlen(a);//求出字符串长度,strlen()函数能求出字符串长度
	lena=4*len+1;//求出输出字符矩阵的长度,宽度恒为五
	memset(b,'.',sizeof(b));//将b数组全赋值为‘.’,以便后来使用
	while(ll<=lena){//开始循环
		aa++;//到第aa个字母
		if(aa%3==0)c='*';
		else c='#';//若为3的倍数个,则用‘*’
		b[3][ll]=a[aa-1];//把字母填入b数组中
		b[1][ll]=c;
		b[5][ll]=c;
		b[2][ll-1]=c;
		b[2][ll+1]=c;
		b[4][ll-1]=c;
		b[4][ll+1]=c;//根据字母的位置推出其他字符的位置,并填入b数组中
		if(b[3][ll-2]!='*')b[3][ll-2]=c;
		if(b[3][ll+2]!='*')b[3][ll+2]=c;//特判,若以被‘*’覆盖,则不能被‘#’覆盖
		ll+=4;//之后每个字母的为止为前一个加4
	}
	for(int i=1;i<=5;i++){
		for(int j=1;j<=lena;j++)
			cout<<b[i][j];//输出
		cout<<endl;//不要忘了每行要加回车
	}
	return 0;//end
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值