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

分析:

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. Android中的Sqlite中的onCreate方法和onUpgrade方法的执行时机--(转)

    原文:http://blog.csdn.net/jiangwei0910410003/article/details/46536329 今天在做数据库升级的时候,遇到一个问题,就是onCreate方法 ...

  2. spring mvc ,spring boot 整合swagger

    https://blog.csdn.net/qq_35992900/article/details/81274436

  3. require - 引入文件

    导入 /** * Creates the node for the load command. Only used in browser envs. */ req.createNode = funct ...

  4. 「JSOI2008」Blue Mary的旅行

    传送门 Luogu 解题思路 分层图加网络流,有点像这题 可以证明最多不超过100天,所以才可以分层,不然图的规模会很大. 首先连源点汇点: \((s,1,INF), (n, t, INF)\) 以时 ...

  5. 循环调用spring的dao,数个过后无响应

    循环调用spring的dao,数个过后无响应 博客分类: spring daospringssh      最近遇到这么一个问题:前台按钮发送AJax请求到后台,后台是SSH框架.每点击一下按钮就发送 ...

  6. linux下mysql允许远程连接

    1. MySql安装教程 https://dev.mysql.com/doc/refman/5.7/en/linux-installation-yum-repo.html 默认情况下mysq的 roo ...

  7. ubuntu 环境下pycharm的 安装与激活教程

    1. 基本安装: 1.1 打开Ubuntu的应用市场,并在搜索栏搜索pycharm,结果如下图所示 1.2 选择pro版本进行安装,结果如下图所示: 1.3打开安装后的pycharm,如果出现下图所示 ...

  8. 扩展的Sobel 算子

    Custom Extended Sobel Filters  https://arxiv.org/pdf/1910.00138.pdf sobel算子是进行边缘检测的一个重要算子.它通常是一个3x3的 ...

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

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

  10. node - DeprecationWarning: Mongoose: `findOneAndUpdate()` and `findOneAndDelete()` without the `use

           1,  原因是因为:findOneAndUpdate()内部会使用findAndModify驱动,驱动即将被废弃,所以弹出警告!附上官方解释:Mongoose v5.5.8: Depre ...