题目描述:

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 d
l l
lowor
a m
c o
. c
jobdu. 题目来源:http://ac.jobdu.com/problem.php?pid=1464
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
char s[];
int main()
{
while(scanf("%s",s)!=EOF)//gets WA
{
int len=strlen(s);
int n1=max(min((len-)/,(len+)/),);
n1--;
int n2=len-n1*;
for(int i=;i<n1;i++)
{
printf("%c",s[i]);
for(int j=;j<n2-;j++)
{
printf(" ");
}
printf("%c\n",s[len-i-]);
}
for(int i=n1;i<len-n1;i++)
{
printf("%c",s[i]);
}
printf("\n");
} return ;
}

2012年浙大:Hello World for U的更多相关文章

  1. 2012年浙大:Head of a Gang

    题目描述: One way that the police finds the head of a gang is to check people's phone calls. If there is ...

  2. 2012年浙大:Sharing

    题目描述: To store English words, one method is to use linked lists and store a word letter by letter. T ...

  3. Windows server 2012 添加中文语言包(英文转为中文)(离线)

    Windows server 2012 添加中文语言包(英文转为中文)(离线) 相关资料: 公司环境:亚马孙aws虚拟机 英文版Windows2012 中文SQL Server2012安装包,需要安装 ...

  4. Windows Server 2012 NIC Teaming介绍及注意事项

    Windows Server 2012 NIC Teaming介绍及注意事项 转载自:http://www.it165.net/os/html/201303/4799.html Windows Ser ...

  5. 1.初始Windows Server 2012 R2 Hyper-V + 系统安装详细

    干啥的?现在企业服务器都是分开的,比如图片服务器,数据库服务器,redis服务器等等,或多或少一个网站都会用到多个服务器,而服务器的成本很高,要是动不动采购几十台,公司绝对吃不消的,于是虚拟化技术出来 ...

  6. 0.Win8.1,Win10,Windows Server 2012 安装 Net Framework 3.5

    后期会在博客首发更新:http://dnt.dkill.net 网站部署之~Windows Server | 本地部署:http://www.cnblogs.com/dunitian/p/482280 ...

  7. windows 2012 r2 can't find kb2919355

    问题   解决: 1.手动安装了 Windows8.1-KB2919442-x64 2.手动下载 KB2919355 更新成功     Turns out to have been a result ...

  8. Windows Server 2012 磁盘管理之 简单卷、跨区卷、带区卷、镜像卷和RAID-5卷

    今天给客户配置故障转移群集,在Windows Server 2012 R2的系统上,通过iSCSI连接上DELL的SAN存储后,在磁盘管理里面发现可以新建 简单卷.跨区卷.带区卷.镜像卷.RAID-5 ...

  9. VMware下Windows Server 2012添加新磁盘

    系统管理员在VM下新装了一台Windows Server 2012服务器,我在上面安装了SQL Server 2014 Standard版数据库,安装之初,只分配了一个C盘,我想在这台服务器上添加了三 ...

随机推荐

  1. 目标检测之基础hessian matrix ---海森矩阵

    就是海赛(海色)矩阵,在网上搜就有. 在数学中,海色矩阵是一个自变量为向量的实值函数的二阶偏导数组成的方块矩阵, Hessian矩阵是多维变量函数的二阶偏导数矩阵,H(i,j)=d^2(f)/(d(x ...

  2. Oracle exp使用正則表達式导出部分表

    假设数据库中有许多张表,而我们又仅仅想导出须要的那几张能够使用例如以下命令 --仅仅导出test1.test2表 exp myname/mypassword@orcl file = d:\my.dmp ...

  3. String知识点

  4. GS发包到MS

    GS发包到MS(GS,MS包交互过程) 例:人物上线 首先看看其实如何确定是哪张地图的 数据库首先只保存一个mapid 在share初始化的时候已经初始化了所有map,并保存了map的指针信息,其ke ...

  5. EasyDSS流媒体解决方案之多方式虚拟直播方法

    EasyDSS_Solution虚拟直播 EasyDSS_Solution虚拟直播,是EasyDSS流媒体解决方案提供的虚拟直播方案.可以通过三种方式创建虚拟直播. (1)点播的视频文件: (2)本地 ...

  6. Linux 设置mysql开机启动

    linux开启启动的程序一般放在/etc/rc.d/init.d/里面,/etc/init.d/是其软连接 mysql设为linux服务 cp /usr/local/mysql/support-fil ...

  7. jQuery 插件开发(1)

    JavaScript 是一门混乱的语言,好的特性和坏的特性混杂在一起.而不同浏览器对标准的解析不一致,使得这门语言更加混乱,在这种情况下遵循最佳实践有诸多好处,至少不会掉入坑里.所以就有了<Ja ...

  8. PHP Framework

    PHP Framework is built for PHP developers who need elegant toolkit to create full-featured web appli ...

  9. Java反射详解(转)

    原文地址:http://www.importnew.com/17616.html 动态语言 动态语言,是指程序在运行时可以改变其结构:新的函数可以被引进,已有的函数可以被删除等在结构上的变化.比如众所 ...

  10. webpack-dev-server原理及要点笔记

    webpack-dev-server启动了一个使用express的Http服务器,这个服务器与客户端采用websocket通信协议,当原始文件发生改变,webpack-dev-server会实时编译. ...