Advertisement
tumaryui

Untitled

Mar 10th, 2020
207
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.12 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. #include <vector>
  4. #include <algorithm>
  5.  
  6. using namespace std;
  7.  
  8. void del(vector<string> &v, string aim, vector<string> &other) {
  9. for(int i = 0; i < v.size(); i++) {
  10. if(v[i].find(" " + aim + " ") != string::npos || v[i].find(" " + aim) != string::npos || v[i].find(aim + " ") != string::npos) {
  11. other.push_back(v[i]);
  12. v.erase(v.begin() + i);
  13. i--;
  14. }
  15. }
  16. }
  17.  
  18. bool cmp(string a, string b) {
  19. return a.size() < b.size();
  20. }
  21. main() {
  22. int n;
  23. cin >> n;
  24. vector<string> v(n), other;
  25. getchar();
  26. for(int i = 0; i < n; i++) {
  27. getline(cin, v[i]);
  28. }
  29. string aim;
  30. cin >> aim;
  31. del(v, aim, other);
  32. cout << "Sort by(inter number):\n1)Phrase length\n2)Aplphabet\n";
  33. int id;
  34. cin >> id;
  35. if(id == 1) {
  36. sort(v.begin(), v.end(), cmp);
  37. sort(other.begin(), other.end(), cmp);
  38. } else {
  39. sort(v.begin(), v.end());
  40. sort(other.begin(), other.end());
  41. }
  42. cout << "First\n";
  43. for(auto it: v) {
  44. cout << it << endl;
  45. }
  46. cout << "Second\n";
  47. for(auto it: other) {
  48. cout << it << endl;
  49. }
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement