You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

30 lines
553 B

#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;
}