'commit'
This commit is contained in:
29
C++专题课程/字符串操作/字符串基本知识.cpp
Normal file
29
C++专题课程/字符串操作/字符串基本知识.cpp
Normal file
@@ -0,0 +1,29 @@
|
||||
#include<bits/stdc++.h>
|
||||
using namespace std;
|
||||
int main() {
|
||||
//1<><31><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
string source = "1234567890";
|
||||
int size=source.length();
|
||||
cout << size << endl;
|
||||
//2<><32>ѭ<EFBFBD><D1AD><EFBFBD><EFBFBD>װ
|
||||
string target="";
|
||||
while(true) {
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user