30 lines
582 B
C++
30 lines
582 B
C++
#include<bits/stdc++.h>
|
|
using namespace std;
|
|
int main() {
|
|
//1、计算字符串长度
|
|
string source = "1234567890";
|
|
int size=source.length();
|
|
cout << size << endl;
|
|
//2、循环组装
|
|
string target="";
|
|
while(true) {
|
|
//出口条件
|
|
if(source.length()==0) {
|
|
break;
|
|
}
|
|
target=target+source[0];
|
|
source=source.substr(1,source.length()-1);
|
|
if(source.length()>=2) {
|
|
source=source.substr(2,source.length()-2)+source.substr(0 , 2);
|
|
}
|
|
cout<<"source:"<<source<<endl;
|
|
cout<<"target:"<<target<<endl;
|
|
cout<<endl;
|
|
}
|
|
cout<<target<<endl;
|
|
return 0;
|
|
}
|
|
|
|
|
|
|