2012年浙大:Hello World for U
- 题目描述:
-
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
lowoThat 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的更多相关文章
- 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 ...
- 2012年浙大:Sharing
题目描述: To store English words, one method is to use linked lists and store a word letter by letter. T ...
- Windows server 2012 添加中文语言包(英文转为中文)(离线)
Windows server 2012 添加中文语言包(英文转为中文)(离线) 相关资料: 公司环境:亚马孙aws虚拟机 英文版Windows2012 中文SQL Server2012安装包,需要安装 ...
- Windows Server 2012 NIC Teaming介绍及注意事项
Windows Server 2012 NIC Teaming介绍及注意事项 转载自:http://www.it165.net/os/html/201303/4799.html Windows Ser ...
- 1.初始Windows Server 2012 R2 Hyper-V + 系统安装详细
干啥的?现在企业服务器都是分开的,比如图片服务器,数据库服务器,redis服务器等等,或多或少一个网站都会用到多个服务器,而服务器的成本很高,要是动不动采购几十台,公司绝对吃不消的,于是虚拟化技术出来 ...
- 0.Win8.1,Win10,Windows Server 2012 安装 Net Framework 3.5
后期会在博客首发更新:http://dnt.dkill.net 网站部署之~Windows Server | 本地部署:http://www.cnblogs.com/dunitian/p/482280 ...
- windows 2012 r2 can't find kb2919355
问题 解决: 1.手动安装了 Windows8.1-KB2919442-x64 2.手动下载 KB2919355 更新成功 Turns out to have been a result ...
- Windows Server 2012 磁盘管理之 简单卷、跨区卷、带区卷、镜像卷和RAID-5卷
今天给客户配置故障转移群集,在Windows Server 2012 R2的系统上,通过iSCSI连接上DELL的SAN存储后,在磁盘管理里面发现可以新建 简单卷.跨区卷.带区卷.镜像卷.RAID-5 ...
- VMware下Windows Server 2012添加新磁盘
系统管理员在VM下新装了一台Windows Server 2012服务器,我在上面安装了SQL Server 2014 Standard版数据库,安装之初,只分配了一个C盘,我想在这台服务器上添加了三 ...
随机推荐
- 完好用户体验: 活用window.location与window.open解决页面跳转问题
原文地址: JavaScript Redirects and window.open原文日期: 2014年08月27日翻译日期: 2014年08月31日翻译人员: 铁锚 (译者注: 本文解决的是按 C ...
- Nginx与Apache的Rewrite规则的区别
一.Nginx Rewrite规则相关指令 Nginx Rewrite规则相关指令有if.rewrite.set.return.break等,其中rewrite是最关键的指令.一个简单的Nginx R ...
- TP 接收post请求使用框架自带函数I()防止注入
<input id="dele_id[]" value="1" type="checkbox" /> <input id= ...
- 目标检测之行人检测(Pedestrian Detection)---行人检测之简介0
一.论文 综述类的文章 [1]P.Dollar, C. Wojek,B. Schiele, et al. Pedestrian detection: an evaluation of the stat ...
- ASP.NET动态网站制作(3)--css(2)
前言:css分为四次课讲完,第一节课内容见ASP.NET动态网站制作(2)--css(1),接下来的内容会涉及到定位.浮动.盒子模型(第二次课).css的具体应用(第三次课).css3(第四次课).今 ...
- PHP百分号转小数
<?php $a = "20.544545%"; echo (float)$a/100; ?>
- Java中的迭代迭代器Iterator与枚举器Enumeration
Iterator 和 Enumeration区别 Iterator 和 Eumberation都是Collection集合的遍历接口,我们先看下他们的源码接口 package java.util; p ...
- shell执行lua脚本传参数
#lua test.lua 2 5arg[0]= test.lua arg[1]= 2arg[2]= 5 if arg[1] and arg[1] == "2" then prin ...
- CUDA: 共享内存与同步
CUDA C支持共享内存, 将CUDA C关键字__shared__添加到变量声明中,将使这个变量驻留在共享内存中.对在GPU上启动的每个线程块,CUDA C编译器都将创建该变量的一个副本.线程块中的 ...
- 5.JavaScript优化及导航菜单背后的秘密
JavaScript优化及导航菜单背后的秘密 伍星 学习目标1.进一步了解前端优化 学习如何编写良好的 JavaScirpt2.通过导航的学习,了解JavaScirpt的应用 JavaScript在用 ...