九度 1149 子串计算
还是要学习下STL
#include <iostream> #include <stdio.h> #include <map> #include <string.h> #include <string> using namespace std; #define MAXLEN 102 char str[MAXLEN]; int main() { while(scanf("%s",str)!=EOF) { map<string,int> M;//map<string,int> M; for(int i=0;i<strlen(str);++i) { for(int j=i;j<strlen(str);++j) { string temp(str+i,j-i+1); M[temp]++; } } map<string,int>::iterator iter; for(iter=M.begin();iter!=M.end();++iter) { if(iter->second>1) { cout<<iter->first<<" "<<iter->second<<endl; } } } return 0; }