fork download
  1.  
  2. #include<stdio.h>
  3. #include <iostream>
  4. #include <algorithm>
  5. #include <vector>
  6. #include <string>
  7. #include <ctype.h>
  8.  
  9.  
  10. using namespace std;
  11. int main()
  12.  
  13. {
  14. int no_lines=0;
  15. cin>>no_lines;
  16. cin.ignore();
  17.  
  18. string line;
  19. vector<string> vec; // vector to store the words
  20. int vecsize=0;
  21. for(int i=0;i<no_lines;i++)
  22. {
  23. getline(cin,line);
  24.  
  25. for(int i=0;i<line.length();i++) // convert to lower-case
  26. {
  27. line[i]=tolower(line[i]);
  28. }
  29.  
  30. int str_start;
  31. int c;
  32. int str_end=0;
  33. int i=0;
  34. while(i<line.length())
  35. {
  36.  
  37. c=0;
  38. while(line[i]>96 && line[i] <123) // splitting the words
  39. {
  40. if (c==0)
  41. {
  42. str_start=i;
  43. }
  44. c++;
  45. i++;
  46. }
  47. str_end= str_start+c-1;
  48. i++;
  49.  
  50. if(c!=0)
  51. {
  52. string okay = line.substr(str_start,c);
  53. if((find(vec.begin(), vec.end(), okay))== vec.end())
  54. {
  55. vec.push_back(okay);
  56. vecsize++;
  57. }
  58.  
  59. }
  60. //cout<<"start:"<<str_start<<endl;
  61.  
  62.  
  63. }
  64. }
  65. sort(vec.begin(),vec.end());
  66.  
  67. cout<<vecsize<<endl;
  68. for(int i=0;i<vecsize;i++)
  69. {
  70. cout<<vec[i]<<endl;
  71. }
  72. }
  73.  
  74.  
  75.  
  76.  
Success #stdin #stdout 0s 3352KB
stdin
Standard input is empty
stdout
0