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

分析:

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. 爱屋吉屋官网、APP停运!互联网房屋中介真的迎来了至暗时刻吗?

    2018年底到2019年初,全球较差的经济大环境终于引来爆炸式的连锁反应.仅从国内的互联网行业来看,很多企业在浪潮退去后都只是在"裸泳".比如被爆料2018年全年亏损109亿元,且 ...

  2. 解决css中display:inline-block产生的空隙问题

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  3. C++ Primer Plus 6 笔记(1)

    1-3章 1.cin.get(),在程序末尾,让窗口一直打开. 2.c++版本的math.h为cmath 3.<< 在c++中是插入运算符,在c中是左移运算符 4.&在C中既表示地 ...

  4. 非阻塞多路IO

    socket.listen() rfds=[] wfds=[] while(select(rfds,wfds,timeout)){//事件循环 client=socket.accept(timeout ...

  5. 环境变量方式使用 Secret【转】

    通过 Volume 使用 Secret,容器必须从文件读取数据,会稍显麻烦,Kubernetes 还支持通过环境变量使用 Secret. Pod 配置文件示例如下: 创建 Pod 并读取 Secret ...

  6. idea跑mapreduce结果为空白文本,idea代码被莫名其妙地改动了

    遇到如题的错误, 一开始查找Step1Main.java的代码错误,尝试关掉分区设置,还是一样. 后来以为是mapper或reducer不执行,网上查找了半天也没有正确原因. 最终,偶然间看到redu ...

  7. CentOS下安装Orcale

    以前没有安装过,最近安装了.感觉在Liunx安装真的超麻烦.这是技术文档,分享给大家. LINUX安装oracle数据库步骤: 1.安装依赖包    yum -y install  gcc gcc-c ...

  8. 浅谈MSF渗透测试

    在渗透过程中,MSF漏洞利用神器是不可或缺的.更何况它是一个免费的.可下载的框架,通过它可以很容易地获取.开发并对计算机软件漏洞实施攻击.它本身附带数百个已知软件漏洞的专业级漏洞攻击工具.是信息收集. ...

  9. R 《回归分析与线性统计模型》page140,5.1

    rm(list = ls()) library(car) library(MASS) library(openxlsx) A = read.xlsx("data140.xlsx") ...

  10. net.sf.json.JSONObject maven下载到了但是java后台一直用不了问题

    需求,实体转JSON,然后用到JSONObject转JSON,但是我向下面这样引入,后台就是用不了,还是报红, <dependency> <groupId>net.sf.jso ...