fork download
  1. #include <iostream>
  2. #include <cstring>
  3. #include <map>
  4. #include <string>
  5.  
  6. using namespace std;
  7.  
  8. typedef map<string, int>::iterator Iter;
  9.  
  10. bool isSymbol(char c)
  11. {
  12. return ( c<'A' || c>'z' || (c<'a' && c>'Z') );
  13. };
  14.  
  15. int main()
  16. {
  17. int freq;
  18. bool beginFlag = true;
  19.  
  20. while(cin >> freq)
  21. {
  22. map<string, int> freqMap;
  23. char word[1000];
  24.  
  25. if(beginFlag)
  26. beginFlag = false;
  27. else
  28. cout << endl;
  29.  
  30. while(1)
  31. {
  32. cin >> word;
  33.  
  34. if(strcmp(word,"EndOfText")==0)
  35. break;
  36.  
  37. // split
  38. string str[2];
  39. int ptr = 0, i = 0;
  40.  
  41. while(word[i])
  42. {
  43. if( isSymbol(word[i]) )
  44. {
  45. ptr++;
  46. }
  47. else
  48. {
  49. str[ptr].push_back( tolower(word[i]) );
  50. }
  51.  
  52. i++;
  53. }
  54.  
  55. for(int j=0; j<2; j++)
  56. {
  57. if(!str[j].empty())
  58. {
  59. if(freqMap.find(str[j])==freqMap.end())
  60. freqMap[str[j]] = 1;
  61. else freqMap[str[j]]++;
  62. }
  63. }
  64. }
  65.  
  66. for(Iter iter = freqMap.begin(); iter!= freqMap.end(); ++iter)
  67. {
  68. if((*iter).second==freq) cout << (*iter).first << endl;
  69. }
  70. }
  71.  
  72. return 0;
  73. }
Success #stdin #stdout 0.01s 5304KB
stdin
3
A NoSQL or Not Only SQL database provides a mechanism for storage and retrieval of data that 
is modeled in means other than the tabular relations used in relational databases. NoSQL databases 
are finding significant and growing industry use in big data and real-time web applications. NoSQL 
systems are also referred to as "Not only SQL" to emphasize that they may in fact allow SQL-like 
query languages to be used. Popular NoSQL databases including Cassandra, HBase, MongoDB and SimpleDB.
EndOfText
stdout
databases
sql
to