现在的位置: 首页 > 综合 > 正文

HDOJ HDU 1200 To and Fro ACM 1200 IN HDU

2012年04月21日 ⁄ 综合 ⁄ 共 908字 ⁄ 字号 评论关闭
//MiYu原创, 转帖请注明 : 转载自 ______________白白の屋

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

很简单的题目, 直接用库函数模拟就可以了
代码 :

//MiYu原创, 转帖请注明 : 转载自 ______________白白の屋
#include <iostream>
#include 
<string>
#include 
<algorithm>
using namespace std;
string words[21];
int main ()
{
    
string str;
    
int col;
    
while ( cin >> col, col )
    
{
           cin 
>> str;
           
int row = str.size () / col ;
           
for ( int i = 0; i < row; ++ i )
           
{
                 
string temp ( str, i * col, col );
                 
if ( i & 1 )
                 
{
                      reverse ( temp.begin(), temp.end() ); 
                 }

                 words[i] 
= temp;
           }
 
           
for ( int j = 0; j != col; ++ j )
           
{
                 
for ( int i = 0; i != row; ++ i )
                 
{
                       cout 
<< words[i][j]; 
                 }
 
           }

           cout 
<< endl;
    }
    
    
return 0
}

抱歉!评论已关闭.