Advertisement
jujisan

Untitled

Oct 23rd, 2017
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.57 KB | None | 0 0
  1. #define lli long long int
  2. #define sf scanf
  3. #define pf printf
  4. #include<bits/stdc++.h>
  5. using namespace std;
  6. int main()
  7. {
  8. freopen("C:\\Users\\DELL\\Documents\\input.txt","rt",stdin);
  9. freopen("C:\\Users\\DELL\\Documents\\output.txt","wt",stdout);
  10. lli i,l,no,flag=0;
  11. set<string> s;
  12. string ch,str;
  13. while(cin>>ch)
  14. {
  15. for(i=0; i<ch.size(); i++)
  16. {
  17. //cout<<"j"<<endl;
  18. flag=0;
  19. if(ch[i]>='a'&&ch[i]<='z')continue;
  20. else if(ch[i]>='A'&&ch[i]<='Z') ch[i]+=32;
  21. else if(ch[i]=='.'||ch[i]=='"')
  22. {
  23. ch.erase(ch.begin()+i);
  24. i--;
  25. }
  26. else
  27. {
  28. if(i==0)
  29. {
  30. s.erase(s.begin());
  31. i=-1;
  32. }
  33. else
  34. {
  35.  
  36. str.append(ch.begin(),ch.begin()+i);
  37. ch.erase(ch.begin(),ch.begin()+i+1);
  38. l=str.length();
  39. if(l==1&&str[0]!=' ')
  40. {
  41. s.insert(str);
  42. }
  43. else if(l)
  44. s.insert(str);
  45. i=-1;
  46. }
  47. }
  48.  
  49. }
  50. str.clear();
  51. l=ch.length();
  52. if(l==1&&ch[0]!=' ')
  53. {
  54. s.insert(ch);
  55. }
  56. else if(l)
  57. s.insert(ch);
  58. }
  59. for(set<string>::iterator it=s.begin(); it!=s.end(); it++)
  60. {
  61. cout<<*it<<endl;
  62. }
  63. return 0;
  64. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement