2012浙大复试上机题Helloworld

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.
#include <iostream>
#include <string>
using namespace std;

int main()
{
	string s;
	int len;
	int i, j;

	while(cin >> s)
	{
		len = s.length() + 2;

		if(len % 3 == 0)
		{
			for(i = 0; i < len/3; i++)
			{
				cout << s[i];
				if(i != len/3 - 1)
				{
					for(j = 0; j < len / 3 - 2; j++)
						cout << " ";
					cout << s[s.length()-1-i] << endl;
				}
			}

			for(i = len / 3; i < 2 * (len/3) - 1; i++)
				cout << s[i];
		}
		else if(len % 3 == 1)
		{
			for(i = 0; i < len/3; i++)
			{
				cout << s[i];
				if(i != len/3 - 1)
				{
					for(j = 0; j < len / 3 - 1; j++)
						cout << " ";
					cout << s[s.length()-1-i] << endl;
				}
			}

			for(i = len / 3; i < 2 * (len/3); i++)
				cout << s[i];
		}
		else
		{
			for(i = 0; i < len/3; i++)
			{
				cout << s[i];
				if(i != len/3 - 1)
				{
					for(j = 0; j < len / 3; j++)
						cout << " ";
					cout << s[s.length()-1-i] << endl;
				}
			}

			for(i = len / 3; i < 2 * (len/3) + 1; i++)
				cout << s[i];
		}
		cout << endl;
	}
	return 0;
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
浙江大学 vc 复试上机是指浙江大学学习计算机科学与技术专业的研究生报考者在通过初试后,需要参加复试环节中的上机考试。 浙江大学 vc 复试上机考试一般会要求考生在电脑上完成一系列与计算机相关的任务,以便评估他们的计算机应用能力和解决问的能力。这样的考试形式主要是为了了解考生的实际操作能力和对计算机常用工具和编程语言的掌握程度。 在考试中,考生可能会面临不同种类的目,如编程、算法设计、数据库操作等,具体内容可能包括但不限于以下几个方面: 1. 编程能力和算法设计:考生可能需要完成一些简单的编程任务,如编写一个程序来实现某种功能,或者对给定的算法进行分析和实现。 2. 数据库操作:考生可能需要处理一些数据库相关的任务,如查询、插入、删除等。 3. 网络通信与安全:考生可能会涉及到网络通信和安全相关的问,如网络协议的理解和运用、网络安全漏洞的分析和修复等。 4. 计算机系统与底层知识:考生可能会遇到一些与计算机系统、底层知识相关的目,如操作系统的功能和机制、计算机组成原理等。 5. 数据结构与算法:考生可能会需要对给定的数据结构进行操作和分析,并设计相应的算法解决相关问。 在准备浙江大学 vc 复试上机考试时,考生应该系统地复习计算机相关知识,熟悉常用工具和编程语言,并多进行一些实际操作练习,以增强自己的动手能力和解决问的能力。同时,考生应该遵守考试规则,保持冷静、稳定的心态,高效解,展现自己的优势和能力。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值