(使用STL自带的排序函数进行排序7.3.6)POJ 2945 Find the Clones拷贝相同次数的文本出现了多少次()
来源:互联网 发布:网络上赌博怎么处罚 编辑:程序博客网 时间:2024/06/01 09:55
/* * POJ_2945.cpp * * Created on: 2013年11月1日 * Author: Administrator */#include <iostream>#include <cstdio>#include <cstring>#include <string>#include <algorithm>using namespace std;const int maxn = 20010;string strs[maxn];int ans[maxn];int main(){int n,m;while(scanf("%d%d",&n,&m)!=EOF,n||m){memset(ans,0,sizeof(ans));int i;for(i = 0 ; i < n ; ++i){cin >>strs[i];}sort(strs,strs+n);//注意,只是对strs[0]~strs[n-1]的数据进行排序int k = 0;//k: 拷贝的次数for(i = 1 ; i <= n; ++i){//如过写成i = 0 ; i < n,采用这种方式进行比较会WAif(strs[i] == strs[i-1]){//第i个字符串与第i-1个字符串相等k++;//拷贝的次数+1}else{ans[k]++;//ans[k]: 拷贝了k次的字符串有多少份k=0;}}for(i = 0 ; i < n ; ++i){printf("%d\n",ans[i]);}}return 0;}
- (使用STL自带的排序函数进行排序7.3.6)POJ 2945 Find the Clones拷贝相同次数的文本出现了多少次()
- (使用STL自带的排序函数进行编程7.3.14)UVA 10062 Tell me the frequencies!(求一个字符出现的次数(包括字母和数字)&&按出现的次数降序)
- (使用STL自带的排序功能进行排序7.3.2)POJ 2092 Grandpa is Famous(结构体排序)
- (使用STL自带的排序功能进行排序7.3.7)POJ 2726 Holiday Hotel(结构体排序)
- (使用STL自带的排序功能进行排序)POJ 1877 Flooded!()
- (使用STL自带的排序函数7.3.4)POJ 2371 Questions and answers(sort()函数的使用)
- (STL自带的排序功能的使用7.1.2)POJ 2388 Who's in the Middle(sort()函数的使用)
- poj 2945 Find the Clones trie树的简单应用
- POJ 2945 Find the Clones
- poj 2945 Find the Clones
- poj 2945 Find the Clones
- POJ 2945 Find the Clones
- poj 2945 Find the Clones
- C++ STL自带的排序sort()
- poj 2945 Find the clones (tire树)
- POJ 2945 Find the Clones Hash
- POJ 2945 - Find the Clones(字典树)
- POJ 2945 Find the Clones 水
- 指向指针的指针
- poj1260Pearls
- java 启动线程三种方式
- 需要懂一点点的SEO和搜索排名(笔记)
- 论mongodb
- (使用STL自带的排序函数进行排序7.3.6)POJ 2945 Find the Clones拷贝相同次数的文本出现了多少次()
- leetcode Palindrome Partitioning I II
- 监控视频中人的特征识别
- DLNA
- VC编程 设置IE浏览器代理(不需重启浏览器)
- HDU1358--KMP找周期(KMP基本题型到此总结完毕)
- xxx is not in the sudoers file解决方法
- 补全MyReview database中的zmax_text table的方法(解决Zmax_Exception问题)
- EF版本变化及一些重要变更