题目描述:

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. checkStyle使用具体解释

    简单介绍 checkStyle是一款代码格式检查工具.它依据设置好的编码规则来自己主动检查代码.比方命名规范,文件长度.代码行长度等等.代码检查工具是保证项目代码质量.统一编码风格的一种重要途径.本篇 ...

  2. 06 php 单例模式

    一:单例模式的三大原则 (1)构造函数需要标记为非public(防止外部使用new操作符创建对象),单例类不能在其他类中实例化,只能被自身实例化. (2)拥有一个保存类的实例的静态成员变量$_inst ...

  3. WPF之DataGrid篇:DataGridComboBoxColumn

    准备数据源   1 准备数据源.基类为Student,数据对象为Student3,数据集为StuList3. END 编辑DataGrid显示列   1 若要填充下拉列表,请首先使用下列选项之一设置 ...

  4. 可展开的UITableView (附源码)

    本文转载至 http://www.apkbus.com/forum.php?mod=viewthread&tid=137207&extra=page%3D1 由于工作需要,写了一个UI ...

  5. 用apache做为代理下载本地pdf文件

    有一些公司会用apache做为代理,下载服务器上的pdf文件.以下是apache做为代理的配置 一. 环境 centos6.5  192.168.69.3 二. yum安装apache 服务 [zxj ...

  6. EasyPlayerPro windows播放器之多窗口播放音量控制方法

    EasyPlayerPro-win基础版本的音频播放为单一通道播放,即同一时间仅允许一个通道播放声音,现应客户需求,在基础版本上实现独立的音频播放,即每个通道可同时播放视频和音频; 设计思路 将音频播 ...

  7. 【题解】P2602[JZOI2010]数字计数

    [题解][P2602ZJOI2010]数字计数 乍看此题,感觉直接从数字的位上面动手,感觉应该很容易. 但是仔细看数据范围,发现如果不利用计数原理,肯定会超时,考虑数码出现的特征: \(A000\)到 ...

  8. centos安装php5.6

    配置yum源 追加CentOS 6.5的epel及remi源. # rpm -Uvh http://ftp.iij.ad.jp/pub/linux/fedora/epel/6/x86_64/epel- ...

  9. 我的Android进阶之旅------>真正在公司看几天代码的感触

    仅以此文来回顾这一周我的工作情况,以及由此而触发的感想. ============================================================= 来到新公司5天了, ...

  10. image auto fix the View

    image: { flex: 1, width: null, height: null, resizeMode: 'contain' }