HDU--1200:To and Fro (字符串)

来源:互联网 发布:网络摄像机安装图解 编辑:程序博客网 时间:2024/05/22 08:04

1. 题目源地址:http://acm.hdu.edu.cn/showproblem.php?pid=1200

2. 解题代码:

#include<iostream>#include<stdio.h>using namespace std;int main(){    int row,column,len;    int i,j,m;    char a[210],b[210][210];        while(cin>>column && column)    {       getchar();       cin>>a;       len=strlen(a);              row=len/column;              m=0;       for(i=0;i<row;i++)       {          for(j=0;j<column;j++)          {             if(i%2==0)             {                b[i][j]=a[m];                m++;             }             else             {                b[i][column-1-j]=a[m];                m++;             }          }       }              for(j=0;j<column;j++)       {          for(i=0;i<row;i++)             cout<<b[i][j];       }       cout<<endl;    }    return 0;}


0 0
原创粉丝点击