//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;
}
#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;
}