题解:P17173 「MSOI R1」回响
OliviaRodrigo · · 题解
P17173 题解【准大一勇闯c++版】
Hello臭贝贝们又到了新生代成功人士娅娅的微服私访时间!
完全入门级别题目呀 没有什么思维难度 直接顺着题目的意思写代码就好了呀 更多请看注释
#include <bits/stdc++.h>
using namespace std;
string s;
bool dir=false;
//false -> / true <-
string ans="";
int main(){
cin>>s;
int len=s.length();
int len1=len;
//因为每次字符串长度都会变 用一个len来储存长度
while(len){
string APT="";
if(dir==false){//如果是从左到右
for(int i=0;i<len;i++){
APT+=s[i];
}
}else{//如果是从右到左
for(int i=len1-1;i>len1-len-1;i--){
APT+=s[i];
}
}
len--;
ans+=APT;
if(dir==false){
dir=true;
}else{
dir=false;
}
}
cout<<ans<<endl;
return 0;
}