http://acm.hdu.edu.cn/showproblem.php?pid=1200
这题算法简单的解密,一个句子,去掉空格,按n数竖着写下来,然后逐行left-to-right and right-to-left,写成结果,要求你把原来的句子写出来,我的思路的一步一步返回去做,原来看着好像很麻烦,代码一次ac貌似还是蛮简单的
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
#include<stdio.h> #include<string.h> int main() { int i,j,k,len,n; char s[2010],t[2010][25]; while(scanf("%d",&n)&&n) { gets(s); gets(s); len=strlen(s); for(i=0;i<len/n;i++) { if(i%2==0) for(j=0;j<n;j++) t[i][j]=s[i*n+j]; else for(j=n-1;j>=0;j--) t[i][n-j-1]=s[i*n+j]; } for(i=0;i<n;i++) for(j=0;j<len/n;j++) printf("%c",t[j][i]); printf("\n"); } return 0; }