九度OnlineJudge之1464:Hello World for U
来源:互联网 发布:java编程思想中文版pdf 编辑:程序博客网 时间:2024/05/17 23:50
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 d
e l
l r
lowo
That is, the characters must be printed in the original order, starting top-down from the left vertical line with n1 characters, 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.
- 输入:
There are multiple test cases.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.
- 输出:
For each test case, print the input string in the shape of U as specified in the description.
- 样例输入:
helloworld!ac.jobdu.com
- 样例输出:
h !e dl llowora mc o. cjobdu.
#include <iostream>#include <string>#include <string.h> using namespace std; int main(){ char str[81]; while(cin>>str) { int len = strlen(str); int x = (len+2)/3; for (int i=0;i<x-1;i++) { cout<<str[i]; for (int j=x-1;j<(len-1-x);j++) cout<<" "; cout<<str[len-1-i]; cout<<endl; } for (int j=x-1;j<(len-1-(x-2));j++) cout<<str[j]; cout<<endl; } //system("pause"); return 0;}
- 九度OnlineJudge之1464:Hello World for U
- 九度1464:Hello World for U
- 1464 Hello World for U 九度Online Judge
- 九度:1464<Hello World For U><排版>
- 九度 OJ 1464 Hello World for U
- 九度OJ 1464 Hello World for U
- 九度OJ 题目1464:Hello World for U
- 九度OJ-题目1464:Hello World for U
- 九度oj-1464-Hello World for U
- 九度 题目1464:Hello World for U
- 九度OJ-1464:Hello World for U
- 【学习笔记】〖九度OJ〗题目1464:Hello World for U
- 九度oj 题目1464:Hello World for U 【ZJU2012考研机试题1】
- 九度考研真题 浙大 2012-1浙大1464:Hello World for U
- Hello World for U
- Hello World for U
- Hello World for U
- Hello World for U
- nyoj 97 兄弟郊游问题
- auto_ptr解析
- 播放IPod音乐
- 【RSLogix5000】—丫的得学习RSLogix5000编程啦!
- java中静态(static)的方法为什么不能重写(override)
- 九度OnlineJudge之1464:Hello World for U
- 在js中直接获得action中的属性值
- Asterisk 未来之路3.0_0005
- 小功能实现
- 【转载】java中final的意义
- android Theme使用总结
- ANDROID中LAYOUTINFLATER的使用
- php 读取memcache二进制数据
- [转载]android动态布局方法总结