HDU - 1200 To and Fro
题意:给定一个,其实是由一个图按蛇形输出而成的字符串,要求按从左到右,从上到下的顺序输出这个图。
分析:
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的更多相关文章
- 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 ...
- HDOJ/HDU 1200 To and Fro(加密解密字符串)
Problem Description Mo and Larry have devised a way of encrypting messages. They first decide secret ...
- [acm]HDOJ 1200 To and Fro
题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=1200 简单字符串处理,找规律 /* 11509672 2014-08-21 11:32:55 Acc ...
- hdoj 1200 To and Fro
To and Fro Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total ...
- hdu To and Fro
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1200 代码: #include <stdio.h> #include <string ...
- HDU字符串基础题(1020,1039,1062,1088,1161,1200,2017)
并不是很精简,随便改改A过了就没有再简化了. 1020. Problem Description Given a string containing only 'A' - 'Z', we could ...
- 转载:hdu 题目分类 (侵删)
转载:from http://blog.csdn.net/qq_28236309/article/details/47818349 基础题:1000.1001.1004.1005.1008.1012. ...
- HDU 3605:Escape(最大流+状态压缩)
http://acm.hdu.edu.cn/showproblem.php?pid=3605 题意:有n个人要去到m个星球上,这n个人每个人对m个星球有一个选择,即愿不愿意去,"Y" ...
- HDU——PKU题目分类
HDU 模拟题, 枚举1002 1004 1013 1015 1017 1020 1022 1029 1031 1033 1034 1035 1036 1037 1039 1042 1047 1048 ...
随机推荐
- js正则 - 限制用户名只能中文、字母和数字 , 不能包含特殊字符
/^[\u4E00-\u9FA5A-Za-z0-9]+$/
- vue的高级使用技巧
全局组件注册 一般组件应用弊端,比较笨拙繁琐低效,比如我们写了一些组件,需要引用上的时候就通过import导入,那如果是高频繁需要使用的组件,则需要在每个使用的时候都需要引入并注册 假设现在有两个组件
- 引用类型--Date类型
要创建一个日期对象,使用new操作符和Date构造函数即可. var now = new Date() 在调用Date构造函数而不传递参数的情况下,新创建的对象自动获得当前日期和时间.如果想根据特定的 ...
- 防止SQL注入的登录页面
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN""http://www.w3.org/T ...
- 多门店4s管理系统
下载 系统登录用户名与密码:manage/123456
- dataset的reparation和coalesce
/** * Returns a new Dataset that has exactly `numPartitions` partitions, when the fewer partitions * ...
- Python3 中 的 绝对导入 与 相对导入
背景: 在学习tf的时候,看到了from __future__ import absolute_import,所以登记学习一下. 概览: 一般模块导入规则: import xxx时搜索文件的优先级如下 ...
- linux中df和du查看磁盘大小不一致解决方法
挂了一块50G到/data目录下# df -h Filesystem Size Used Avail Use% Mounted on /dev/xvdb1 50G 46G 1.2G 98% /dat ...
- Java并发——volatile的原理
111 Java并发——volatile的原理
- Centos7关闭防火墙 设置开机启动
[root@nmserver-7 ~]# systemctl stop firewalld.service [root@nmserver-7 ~]# systemctl status firewall ...