POJ 2039 To and Fro(水题)

【题目简述】:字符串的简单处理,看懂题意,特别是他给的那个例子就好,很简单

见代码:

#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
using namespace std;

char str[211][211];

int main()
{
	int colum;
	char str1[211];
	int tmp;
	while(cin>>colum,colum)
	{
		cin>>str1;
		int len = strlen(str1);
		tmp = len/colum;
		int count = 0;
		for(int i = 0;i<tmp;i++)
		{
			if(i%2 == 0)
			for(int j = 0;j<colum;j++)
				str[i][j] = str1[count++];
			else
			for(int j = colum-1;j>=0;j--)
				str[i][j] = str1[count++];
		}
		for(int i = 0;i<colum;i++)
		{
			for(int j = 0;j<tmp;j++)
				cout<<str[j][i];
		}
		cout<<endl;
	}
	return 0;
}
时间: 2025-01-07 13:30:06

POJ 2039 To and Fro(水题)的相关文章

POJ 3030. Nasty Hacks 模拟水题

Nasty Hacks Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 13136   Accepted: 9077 Description You are the CEO of Nasty Hacks Inc., a company that creates small pieces of malicious software which teenagers may use to fool their friends.

poj 3444 Wavelet Compression 模拟水题

水题,直接贴代码. //poj 3444 //sep9 #include <iostream> using namespace std; const int maxN=260; int a[maxN],b[maxN]; int main() { int i,n,m; while(scanf("%d",&n)==1&&n){ for(i=1;i<=n;++i) scanf("%d",&a[i]); m=1; while

【POJ】Cow Multiplication(水题)

Cow Multiplication http://poj.org/problem?id=3673 题意:输入两个数A B,比如123和45   然后算123*45这个运算是指1*4 + 1*5 + 2*4 + 2*5 + 3*4 + 3*5 = 54. 思路:水题. #include<iostream> #include<cmath> #include<cstring> using namespace std; typedef long long ll; const

poj 1004:Financial Management(水题,求平均数)

Financial Management Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 126087   Accepted: 55836 Description Larry graduated this year and finally has a job. He's making a lot of money, but somehow never seems to have enough. Larry has deci

POJ 2656 Unhappy Jinjin(水题)

[题意简述]:找到两数之和最大的那一天. [分析]:这个....代码就贴在题目下啊. #include <stdio.h> int main(){ while(1) { int i, n; int maxday, maxvalue = -1; scanf("%d", &n); if (n == 0) break; for (i = 1; i <= n; i++) { int a, b; scanf("%d%d", &a, &

POJ 2039 To and Fro

To and Fro Description Mo and Larry have devised a way of encrypting messages. They first decide secretly on the number of columns and write the message (letters only) down the columns, padding with extra random letters so as to make a rectangular ar

ACM: POJ 1401 Factorial-数论专题-水题

POJ 1401 Factorial Time Limit:1500MS     Memory Limit:65536KB     64bit IO Format:%lld & %llu Description The most important part of a GSM network is so called Base Transceiver Station (BTS). These transceivers form the areas called cells (this term

POJ 1986 DIstance Query LCA水题

给出一棵树,对于每一个询问,给出2个节点,输出2个节点的距离. 输入中有字母,那个是没有用的,不用管. 思路: 0.选择编号为1的节点作为树的root (注意:有些题的边是单向的,这时候我们要根据节点的入度来确定root, 双向的话一般可以随意选择一个节点作为root) 1.dfs1,求出dep和pa[i][0] 2.初始化数组pa 3.节点(u,v)的权值为w 把本来是边的权值w赋给u,v中dep较大的节点, cost[i]表示节点i的权值为cost[i] 先初始化:cost[root]=0

【POJ 2503】Babelfish(水题)stl map存取即可

题目链接 题目链接 http://poj.org/problem?id=2503 题意 英文A <=> 方言B 输入B,求A 代码如下(G++) #include <iostream> #include <string.h> #include "map" #include "string" using namespace std; typedef long long ll; double eps = 1e-7; map <s