九度 1149 子串计算

http://ac.jobdu.com/problem.php?id=1149

 1 #include <iostream>
2 #include <stdio.h>
3 #include <map>
4 #include <string.h>
5 #include <string>
6 using namespace std;
7
8 char str[110];
9
10 int main()
11 {
12 int len;
13 while(scanf("%s",str)!=EOF){
14 map<string,int> M;
15 len=strlen(str);
16 int i,j;
17 for(i=0;i<len;i++){
18 for(j=i;j<len;j++){
19 string temp(str+i,j-i+1);
20 M[temp]++;
21 }
22 }
23 map<string,int>::iterator it;
24 for(it=M.begin();it!=M.end();it++){
25 if(it->second>1){
26 cout<<it->first<<" "<<it->second<<endl;
27 }
28 }
29 }
30 }



posted @ 2012-02-25 16:05  linyvxiang  阅读(197)  评论(0编辑  收藏  举报