ACM___________________________

______________白白の屋
posts - 182, comments - 102, trackbacks - 0, articles - 0

HDOJ HDU 1200 To and Fro ACM 1200 IN HDU

Posted on 2010-08-04 12:29 MiYu 阅读(496) 评论(2)  编辑 收藏 引用 所属分类: ACM ( 串 )ACM ( 水题 )
//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
}

Feedback

# re: HDOJ HDU 1200 To and Fro ACM 1200 IN HDU [未登录]  回复  更多评论   

2010-08-06 22:14 by Tanky Woo
啊啊啊啊!哥要抓狂啦!!!
哥把大小200堪称100了。


害哥一直TLE

# re: HDOJ HDU 1200 To and Fro ACM 1200 IN HDU   回复  更多评论   

2010-08-07 14:01 by MiYu
啊列 ........ string 无限制.......

只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理