#define use_CRT_SECURE_NO_WARNINGS 1
#include <iostream>
#include <cstring>
using namespace std;
int main() {
setlocale(LC_ALL, "Russian");
const int N = 81;
const int N2 = 81;
int numbers[N];
int count = 0;
int count2 = 0;
string words[N];
string kwords[N2];
char the_string[N], * p;
char* next_token = nullptr;
int i = 0;
for (int k = 0; k < N; k++) {
numbers[k] = 0;
}
cout << "Введите строку:";
cin.getline(the_string, N); // начало ввода первого массива
p = strtok_s(the_string, " ", &next_token);
while (p != nullptr) {
words[i] = p;
i++;
p = strtok_s(nullptr, " ", &next_token);
count++;
} // конец ввода первого массива
cout << endl;
char the_string2[N2], * p2;
char* next_token2 = nullptr;
cout << "Введите нужные слова:";
cin.getline(the_string2, N2);
int j = 0;
p2 = strtok_s(the_string2, " ", &next_token2);
while (p2 != nullptr) {
kwords[j] = p2;
j++;
p2 = strtok_s(nullptr, " ", &next_token2);
count2++;
for (int i = 0; i < count; i++) {
for (int j = 0; j < count2; j++) {
if (words[i] == kwords[j]) {
numbers[j] = numbers[j] + 1;
break;
int t; string d;
for (int i = 0; i < count2; i++) {
if (numbers[i] < numbers[i + 1]) {
t = numbers[i + 1];
numbers[i+1] = numbers[i];
numbers[i] = t;
d = kwords[i + 1];
kwords[i + 1] = kwords[i];
kwords[i] = d;
cout << kwords[i] << " ";
return 0;
#define use_CRT_SECURE_NO_WARNINGS 1
#include <iostream>
#include <cstring>
using namespace std;
int main() {
setlocale(LC_ALL, "Russian");
const int N = 81;
const int N2 = 81;
int numbers[N];
int count = 0;
int count2 = 0;
string words[N];
string kwords[N2];
char the_string[N], * p;
char* next_token = nullptr;
int i = 0;
for (int k = 0; k < N; k++) {
numbers[k] = 0;
}
cout << "Введите строку:";
cin.getline(the_string, N); // начало ввода первого массива
p = strtok_s(the_string, " ", &next_token);
while (p != nullptr) {
words[i] = p;
i++;
p = strtok_s(nullptr, " ", &next_token);
count++;
} // конец ввода первого массива
cout << endl;
char the_string2[N2], * p2;
char* next_token2 = nullptr;
cout << "Введите нужные слова:";
cin.getline(the_string2, N2);
int j = 0;
p2 = strtok_s(the_string2, " ", &next_token2);
while (p2 != nullptr) {
kwords[j] = p2;
j++;
p2 = strtok_s(nullptr, " ", &next_token2);
count2++;
}
cout << endl;
for (int i = 0; i < count; i++) {
for (int j = 0; j < count2; j++) {
if (words[i] == kwords[j]) {
numbers[j] = numbers[j] + 1;
break;
}
}
}
int t; string d;
for (int j = 0; j < count2; j++) {
for (int i = 0; i < count2; i++) {
if (numbers[i] < numbers[i + 1]) {
t = numbers[i + 1];
numbers[i+1] = numbers[i];
numbers[i] = t;
d = kwords[i + 1];
kwords[i + 1] = kwords[i];
kwords[i] = d;
}
}
}
cout << endl;
for (int i = 0; i < count2; i++) {
cout << kwords[i] << " ";
}
return 0;
}