博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
ZJUT OJ 1031
阅读量:7239 次
发布时间:2019-06-29

本文共 1265 字,大约阅读时间需要 4 分钟。

对称串 

Time Limit:1000MS  Memory Limit:32768K

Description:

有一些字串,有些对称,有些不对称,请将对称的串按长度排列。

 

Sample Input:

123321123454321123321sdfsdfd121212\\dd\\

Sample Output:

123321\\dd\\123454321 code :
1 /* 2  3 */ 4 #include 
5 #include
6 #include
7 #include
8 using namespace std; 9 10 struct cmp11 {12 public:13 bool operator () (const string &s1, const string &s2) {14 return s1.length() < s2.length();15 }16 };17 bool is_symmetrical (string str);18 19 int main()20 {21 vector
ve;22 for (string str; cin >> str;) {23 if (is_symmetrical(str))24 ve.push_back(str);25 }26 if (ve.size()) {27 sort(ve.begin(), ve.end(), cmp());28 int i = 0, len = ve.size();29 for (; i < len; i++)30 cout << ve[i] << endl;31 }32 }33 34 bool is_symmetrical (string str) {35 bool symmetry = true;36 int len = str.length(), i = 0;37 for (; i < len / 2; i++) {38 if (str[i] != str[len - i - 1])39 symmetry = false;40 }41 return symmetry;42 }

 

转载于:https://www.cnblogs.com/findingsea/archive/2012/09/11/2679562.html

你可能感兴趣的文章
Keepalive 之 高可用实现
查看>>
Ansible 之 概念和常用模块介绍
查看>>
Python实例:字典运算:查找字典中的最大最小值
查看>>
git rebase(高级)
查看>>
电信2月国内市场份额52.22% 环比上月下降0.61%
查看>>
6月21日全球域名注册商(国际域名)保有量及市场份额
查看>>
批量设置0777
查看>>
centos6对xen4.2的支持
查看>>
用rsync同步公网centos yum源做本地yum源服务器
查看>>
linux sftp
查看>>
Linux的两种随机数生成器
查看>>
freeradius+mysql+pppoe认证
查看>>
与“十“俱进 阿里数据库运维10年演进之路
查看>>
关于运维人员的未来职业生涯
查看>>
git 学习笔记
查看>>
shell中$0,$,$!等的特殊用法
查看>>
FastDFS_V5.05分布式存储安装与使用
查看>>
2014年下半年信息系统项目管理师上午试题试题与答案 37
查看>>
简单可达性分析
查看>>
忘记管理地址巧用Sniffer来解决
查看>>