题意:给定一个,其实是由一个图按蛇形输出而成的字符串,要求按从左到右,从上到下的顺序输出这个图。

分析:

1、把字符串转化成图

2、按要求输出图= =

#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cctype>
#include<cmath>
#include<iostream>
#include<sstream>
#include<iterator>
#include<algorithm>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<stack>
#include<deque>
#include<queue>
#include<list>
#define lowbit(x) (x & (-x))
const double eps = 1e-8;
inline int dcmp(double a, double b){
if(fabs(a - b) < eps) return 0;
return a > b ? 1 : -1;
}
typedef long long LL;
typedef unsigned long long ULL;
const int INT_INF = 0x3f3f3f3f;
const int INT_M_INF = 0x7f7f7f7f;
const LL LL_INF = 0x3f3f3f3f3f3f3f3f;
const LL LL_M_INF = 0x7f7f7f7f7f7f7f7f;
const int dr[] = {0, 0, -1, 1, -1, -1, 1, 1};
const int dc[] = {-1, 1, 0, 0, -1, 1, -1, 1};
const int MOD = 1e9 + 7;
const double pi = acos(-1.0);
const int MAXN = 200 + 10;
const int MAXT = 10000 + 10;
using namespace std;
char s[MAXN];
char pic[MAXN][MAXN];
int main(){
int c;
while(scanf("%d", &c) == 1){
if(!c) return 0;
memset(pic, ' ', sizeof pic);
scanf("%s", s);
int len = strlen(s);
int r = 0;
for(int i = 0; i < len; ++i){
if(i % c == 0) ++r;
if(r & 1){
pic[r][i - (r - 1) * c] = s[i];
}
else{
pic[r][c - (i - (r - 1) * c) - 1] = s[i];
}
}
for(int i = 0; i < c; ++i){
for(int j = 1; j <= r; ++j){
printf("%c", pic[j][i]);
}
}
printf("\n");
}
return 0;
}

  

HDU - 1200 To and Fro的更多相关文章

  1. hdu 1200 To and Fro(简单模拟或DP)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1200 To and Fro Time Limit: 2000/1000 MS (Java/Others ...

  2. HDOJ/HDU 1200 To and Fro(加密解密字符串)

    Problem Description Mo and Larry have devised a way of encrypting messages. They first decide secret ...

  3. [acm]HDOJ 1200 To and Fro

    题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=1200 简单字符串处理,找规律 /* 11509672 2014-08-21 11:32:55 Acc ...

  4. hdoj 1200 To and Fro

    To and Fro Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total ...

  5. hdu To and Fro

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1200 代码: #include <stdio.h> #include <string ...

  6. HDU字符串基础题(1020,1039,1062,1088,1161,1200,2017)

    并不是很精简,随便改改A过了就没有再简化了. 1020. Problem Description Given a string containing only 'A' - 'Z', we could ...

  7. 转载:hdu 题目分类 (侵删)

    转载:from http://blog.csdn.net/qq_28236309/article/details/47818349 基础题:1000.1001.1004.1005.1008.1012. ...

  8. HDU 3605:Escape(最大流+状态压缩)

    http://acm.hdu.edu.cn/showproblem.php?pid=3605 题意:有n个人要去到m个星球上,这n个人每个人对m个星球有一个选择,即愿不愿意去,"Y" ...

  9. HDU——PKU题目分类

    HDU 模拟题, 枚举1002 1004 1013 1015 1017 1020 1022 1029 1031 1033 1034 1035 1036 1037 1039 1042 1047 1048 ...

随机推荐

  1. 第1节 storm编程:7、并行度分析以及如何解决线程安全问题

    storm其实就是一个多进程与多线程的框架 开多个进程:分配到的资源更多 开多个线程:执行的速度更快 设置进程个数以及线程个数 ==================================== ...

  2. 【Python基础知识】【语法】【入门】

    一.Python概述 Python是一门面向对象的编程语言,拥有强大丰富的库,没有操作系统的限制,是一种优美.清晰的编程语言. 二.Python基础语法 1.Python标识符 标识符就是程序中定义的 ...

  3. redis-String字符串

    存储类型:可以用来存储字符串.整数.浮点数. 常用命令: 1. SET key value [EX seconds] [PX milliseconds] [NX|XX] 1.1 EX seconds ...

  4. 069、Java面向对象之对象引用传递

    01.代码如下: package TIANPAN; class Book { // 定义一个新的类 String title; // 书的名字 double price; // 书的价格 public ...

  5. IOS UIKIT_EXTERN, __attribute__((visibility ("default"))) 是啥玩意?

    问题提出 在学习IOS时候,碰到一个函数NSStringFromCGPoint (UIGeometry.h) 其原型是 UIKIT_EXTERN NSString *NSStringFromCGPoi ...

  6. flask-Bootstrap Jinja2 原生 模板 和 jumpserver 模板

    #模板 {% block doc -%} <!DOCTYPE html> <html{% block html_attribs %}{% endblock html_attribs ...

  7. CodeForces - 862C Mahmoud and Ehab and the xor(构造)

    题意:要求构造一个n个数的序列,要求n个数互不相同,且异或结果为x. 分析: 1.因为0 ^ 1 ^ 2 ^ 3 ^ ... ^ (n - 3) ^ (n - 2) ^ (0 ^ 1 ^ 2 ^ 3 ...

  8. 超赞!苹果新一代iPad确定:外形大变样

    导读 除了iPhone.新MacBook Pro外,苹果还准备新款的入门版iPad,这么来看的话,他们要发布的新品真的是太多了. 据产业链最新消息称,苹果将在今年9月份更新入门版iPad,具体来说就是 ...

  9. day03-Python运维开发基础-(数据类型强转、运算符、逻辑短路、isinstance)

    1. 强制转换成容器数据类型 # ### 强制类型转换 容器类型数据 (str list tuple set ) var1 = "你好世界" var2 = ["陈博文&q ...

  10. JS动态判断设备类型为PC或者移动端,然后根据设备加载相应的代码

    这里是通过JS判断设备之后加载相应的网站,如果是移动端加载m开头的网站域名,如果是PC端就加载 www.开头的正式域名 <script> (function () { var url = ...