hdu To and Fro

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1200

代码:

 1 #include <stdio.h>
 2 #include <string.h>
 3 #include <math.h>
 4 #include <algorithm>
 5 #include <iostream>
 6 #include <ctype.h>
 7 #include <iomanip>
 8 #include <queue>
 9 #include <map>
10 #include <stdlib.h>
11 using namespace std;
12
13 char a[25][250],str[300];
14
15 int main()
16 {
17     int lie,hang;
18     int len,i,j,k;
19     while(scanf("%d",&lie),lie){
20         getchar();
21         hang=k=0;
22         memset(a,‘\0‘,sizeof(a));//将字符数组初始化  
23         gets(str);
24         len=strlen(str);
25         hang=len/lie;
26         for(i=0;i<hang && k<len;i++){//将一开始输入的字符按照先从左到右,再从右到左填入二维数组中  
27             for(j=0;j<lie;j++){
28                 if(i%2)//判断是奇数行  
29                     a[i][lie-j-1]=str[k++];
30                 else
31                     a[i][j]=str[k++];
32             }
33         }
34         for(i=0;i<lie;i++)//按顺序输出就可以了,注意是从上到下输出  
35                 for(j=0;j<hang;j++)
36                     printf("%c",a[j][i]);
37             printf("\n");
38     }
39 }
时间: 2024-10-31 13:12:57

hdu 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)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 5129    Accepted Submission(s): 3550 Problem Description Mo and Larry have devised

HDU 1200 To and Fro

To and Fro Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 5493    Accepted Submission(s): 3799 Problem Description Mo and Larry have devised a way of encrypting messages. They first decide sec

HDU ACM 1200 To and Fro

解析:水题,直接模拟. 根据i可得出行为i/col.奇偶数行分别处理,奇数行列序为col-i%col-1,偶数行列序为i%col. #include<iostream> #include<set> #include<algorithm> using namespace std; int main() { char a[105][21]; char b[201]; int i,col,j,k; while(cin>>col && col) {

HDU 3152 Obstacle Course(BFS+优先队列 重载)

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=3152 Problem Description You are working on the team assisting with programming for the Mars rover. To conserve energy, the rover needs to find optimal paths across the rugged terrain to get from its sta

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

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

HDU 5025 Saving Tang Monk(BFS+状压)

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5025 Problem Description <Journey to the West>(also <Monkey>) is one of the Four Great Classical Novels of Chinese literature. It was written by Wu Cheng'en during the Ming Dynasty. In this novel,

[acm]HDOJ 1200 To and Fro

题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=1200 简单字符串处理,找规律 1 /* 2 11509672 2014-08-21 11:32:55 Accepted 3 1200 0MS 380K 442 B G++ 空信高手 4 */ 5 #include<iostream> 6 #include<string> 7 #include<cstdio> 8 using namespace std; 9 int mai

网络流强化-HDU 3338-上下界限制最大流

题意是: 一种特殊的数独游戏,白色的方格给我们填1-9的数,有些带数字的黑色方格,右上角的数字代表从他开始往右一直到边界或者另外一个黑格子,中间经过的白格子的数字之和要等于这个数字:左下角的也是一样的意思,只是作用对象成了它下方的白格子. 思路: 既然所有行的数字之和等于所有列的数字之和,那么我们可以将行方向(向右)的点作为与源点连接的点,列方向(向下)的点作为与汇点连接的点. 由于向右和向下的点可能在同一块方格里面,以及我们需要设置每个白格子的容量,所以我们需要拆点. 题目要求填1-9的数,所

HDU 6203 ping ping ping [LCA,贪心,DFS序,BIT(树状数组)]

题目链接:[http://acm.hdu.edu.cn/showproblem.php?pid=6203] 题意 :给出一棵树,如果(a,b)路径上有坏点,那么(a,b)之间不联通,给出一些不联通的点对,然后判断最少有多少个坏点. 题解 :求每个点对的LCA,然后根据LCA的深度排序.从LCA最深的点对开始,如果a或者b点已经有点被标记了,那么continue,否者标记(a,b)LCA的子树每个顶点加1. #include<Bits/stdc++.h> using namespace std;