HDOJ HDU 1200 To and Fro ACM 1200 IN HDU
Posted on 2010-08-04 12:29 MiYu 閱讀(521) 評論(2) 編輯 收藏 引用 所屬分類: ACM ( 串 ) 、ACM ( 水題 )//MiYu原創, 轉帖請注明 : 轉載自 ______________白白の屋
題目地址 :
http://acm.hdu.edu.cn/showproblem.php?pid=1200
很簡單的題目, 直接用庫函數模擬就可以了
代碼 :
題目地址 :
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;
}














































