a亚洲精品_精品国产91乱码一区二区三区_亚洲精品在线免费观看视频_欧美日韩亚洲国产综合_久久久久久久久久久成人_在线区

首頁 > 學院 > 開發設計 > 正文

PAT A1031. Hello World for U (20)

2019-11-11 05:11:21
字體:
來源:轉載
供稿:網友

Given any string of N (>=5) characters, you are asked to form the characters into the shape of U. For example, "helloworld" can be PRinted as:

h  de  ll  rlowoThat is, the characters must be printed in the original order, starting top-down from the left vertical line with n1characters, then left to right along the bottom line with n2 characters, and finally bottom-up along the vertical line with n3 characters. And more, we would like U to be as squared as possible -- that is, it must be satisfied that n1 = n3 = max { k| k <= n2 for all 3 <= n2 <= N } with n1 + n2 + n3 - 2 = N.

Input Specification:

Each input file contains one test case. Each case contains one string with no less than 5 and no more than 80 characters in a line. The string contains no white space.

Output Specification:

For each test case, print the input string in the shape of U as specified in the description.

Sample Input:
helloworld!Sample Output:
h   !e   dl   llowor
#include <cstdio>#include <algorithm>#include <cmath>#include <cstring>#define Max 110using namespace std;int main(){	char s[Max]={};	int sum=0,x,y,z,f=0;	gets(s);	sum=strlen(s);	x=y=(sum+2)/3;	z=sum+2-2*x;	char ss[Max][Max];	for(int i=0;i<Max;i++)		for(int j=0;j<Max;j++) ss[i][j]=' ';	for(int i=0;i<x;i++) ss[i][0]=s[f++];	for(int i=1;i<z;i++) ss[x-1][i]=s[f++];	for(int i=x-2;i>=0;i--) ss[i][z-1]=s[f++];	for(int i=0;i<x;i++)	{		for(int j=0;j<z;j++)		{							printf("%c",ss[i][j]);					 		}		printf("/n");	}	system("pause");	return 0;}
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 午夜无码国产理论在线 | 中文字幕一二三区 | 中文字幕一区二区三区免费视频 | 欧美14一18处毛片 | 欧美 日韩 国产 成人 在线 | 黄色免费在线观看 | 三级亚洲 | 欧美亚洲一 | 国产片一区二区三区 | 久久久精品久久久久 | 亚洲九九| 欧美日韩国产精品久久久久 | 色呦呦网 | 美女超碰 | 成人精品 | 黄色影院在线看 | 免费黄色av | 国产成人精品a | 91精品蜜臀一区二区三区在线 | 亚洲精品乱码久久久久久按摩观 | 久草高清 | 中文字幕第一页在线 | 成人免费高清视频 | 久久9久久 | 成年人精品视频在线观看 | 日韩专区在线播放 | 日韩 欧美 自拍 | 日韩欧美在线观看视频 | 91久久国产综合久久 | 青草视频在线免费观看 | 九色网址 | 久久久久黄色 | 国产精品久久久久久久久久99 | 日日爱886 | 91视频在线| 欧美v亚洲 | 一区综合 | 色必久久 | 99精品免费 | 成人男女激情免费视频 | 午夜寂寞福利视频 |