华中科技,最短最长文本
2016-03-07 10:44
369 查看
要注意只有一个字符串的时候,不能重复输出,并且当有字符串都相等时,也不能重复输出
#include<iostream> #include<cstdio> #include<string> using namespace std; int main(){ string str[1000]; //int len[1000];//每个字符串的长度; int min = -1; int max = 0; int count = 0;//字符串数 int flag[1000]; while(cin>>str[count]){ //len[count] = str[count].length(); if(max<str[count].length()) max = str[count].length(); if(min>str[count].length()) min = str[count].length(); count++; } for(int i = 0;i<count;i++){ if(str[i].length()==min){ cout<<str[i]<<endl; flag[i] = 1; } } for(int i = 0;i<count;i++){ if(str[i].length()==max){ if(!flag[i]) cout<<str[i]<<endl; } } }
相关文章推荐
- 专访阿里陈康贤:我所理解的网站架构
- 常见的查找算法
- Dubbo与Zookeeper、SpringMVC整合和使用(负载均衡、容错)
- JAVA对称加密算法汇总及实现
- [转] Android学习系列(29)--App调试的几个命令实践
- [git]用pelican搞一个自己的blog(已完成)
- dfs算法在非图结构中的运用
- haproxy 关闭ssl 3.0 加密
- 科维PLC运行时系统ProConOS embedded CLR 2.2 特定应用
- Vert.x 3学习笔记---14( Web篇 )
- MFS的MASTER启动出现错误
- FAQ 前端面试大杂烩3
- 【Maven】安装Jar包到本地仓库,多个仓库可以指定具体哪个仓库。
- boost-同步-锁选项
- Query cache(高速查询缓冲池)
- 浅表拷贝vs深度拷贝
- 【ShancoLove】带你看蓝桥杯——算法训练Torry的困惑(基本型)
- LeetCode : 4Sum [java]
- Spring4.xx出现无法解析xml文件
- LeetCode 35. Search Insert Position