1031 对称串
Submit solution
Points:
100
Time limit:
1.0s
Memory limit:
32M
Problem types
Allowed languages
C, C++, Java, Python
Description
有一些字串,有些对称,有些不对称,请将对称的串按长度排列。
Sample
Input
123321
123454321
123
321
sdfsdfd
121212
\\dd\\
Output
123321
\\dd\\
123454321
Comments
include<iostream>
include<vector>
include<string>
include<algorithm>
using namespace std; bool s1(const string &s){ int i=0,r=s.size()-1; while(i<r){ if(s[i]!=s[r])return false; i++; r--; } return true; } int main(){ vector<string> arr; string s; while (getline(cin,s)){ if (s.empty())continue; if(s1(s)){ arr.push_back(s); } } sort(arr.begin(),arr.end(),{ return a.size()<b.size(); }); for(auto&str:arr){ cout<<str<<endl; } return 0; }