函数

 1 #include <iostream>
 2 #include <cstring>
 3 using namespace std;
 4 int main()
 5 {
 6     string s="09jslkuteng";
 7     cout<<s.substr(3)<<endl;   //输出下标为3开始到最后的字符串
 8     cout<<s.substr(3,4)<<endl;   //输出下标为3开始的4个字符
 9     return 0;
10 }
11 
12 //输出:
13 //slkuteng
14 //slku
substr
 1 #include <bits/stdc++.h>
 2 using namespace std;
 3 
 4 int main()
 5 {
 6     string s="123asd";
 7     string a=s;
 8     reverse(a.begin(),a.end());
 9     cout<<s<<endl<<a<<endl;
10     return 0;
11 }
12 
13 //结果显示
14 //123asd
15 //dsa321
reverse

 reverse()这个函数在判断字符串的回文方面挺好用的,注意不要拼错。

posted @ 2017-12-18 18:20  凌乱风中  阅读(80)  评论(0编辑  收藏  举报