2039.cpp

来自「poj的几道题」· C++ 代码 · 共 36 行

CPP
36
字号
#include<iostream>
#include<string>
using namespace std;
int main()
{
   int len;
   while(cin>>len&&len!=0)
   {
      string str_1;
      char chr_1;
      int tag,time,i,j,temp,tag_1;
      tag_1=len*2-1;
      getchar();
      while(chr_1=getchar())
         if(chr_1==10) break;
         else 
            str_1+=chr_1;
      time=str_1.length()/len;
      for(i=0;i<len;i++)
         {
            cout<<str_1[i];
            tag=tag_1-2*i;
            temp=i;
            for(j=1;j<time;j++)                
               {
                 temp+=tag;
                 cout<<str_1[temp];
                 tag=len*2-tag;                                                               
               }         
         }                    
       cout<<endl;                 
   }     
   return 0;
    
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?