Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- #include <string>
- #include <cstdlib>
- #include <bits/stdc++.h>
- using namespace std;
- bool car(string c, string z) {
- return c.size() > z.size();
- }
- int main()
- {
- setlocale(LC_ALL, "");
- int n;
- char y;
- cout << "Введите количество фраз" << endl;
- cin >> n;
- string m;
- string a[n];
- vector <string> vac;
- getchar();
- cout << "Введите фразу" << endl;
- for(int i = 0 ; i < n; i++) {
- getline(cin, a[i]);}
- cout << "Введите слово" << endl;
- cin >> m ;
- for(int i = 0 ; i < n; i++) {
- if(a[i].find(m) != string::npos) {
- vac.push_back(a[i]);
- a[i]="-1";
- }
- }
- cout << "Выберите тип сортировки: 1) По длине фразе 2) По алфавиту " << endl;
- cin >> y;
- if (y == '1') {
- sort(a, a + n, car);
- for(int i = 0; i < n; i++)
- if(a[i] != "-1" ) cout << a[i] << "\n";
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement