题目连接:

http://acm.hdu.edu.cn/showproblem.php?pid=1200 

简单字符串处理,找规律


 

 1 /*
 2 11509672    2014-08-21 11:32:55    Accepted    
 3 1200    0MS    380K    442 B    G++    空信高手
 4 */
 5 #include<iostream>
 6 #include<string>
 7 #include<cstdio>
 8 using namespace std;
 9 int main()
10 {
11     //freopen("input.txt","r",stdin);
12     string str;
13     int n,flag=1;
14     while(cin>>n && n!=0)
15     {
16         cin>>str;
17         int pnt;
18         for(int i=1;i<=n;i++)
19         {
20             flag=1;//重置左右
21             pnt=i;
22             while(pnt<=str.length())
23             {
24                 cout<<str[pnt-1];
25                 //左右分别讨论
26                 if(flag){pnt+=(2*n-2*i+1);flag=0;} 
27                 else {pnt+=(2*i-1);flag=1;}
28             }
29         }
30         cout<<endl;
31     }
32     return 0;
33 }

 

相关文章:

  • 2021-09-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-01
  • 2021-05-17
  • 2022-02-22
  • 2021-10-24
  • 2021-12-20
猜你喜欢
  • 2021-12-18
  • 2022-12-23
  • 2021-10-07
  • 2021-08-06
  • 2021-06-03
  • 2021-05-24
  • 2022-12-23
相关资源
相似解决方案