СИ | Поиск повторяющихся слов в массиве
#include <stdio.h>
#include <stdlib.h>
#include <conio.h>
#include <string.h>
#include <math.h>
#include <locale.h>
#include <Windows.h>
void mindl(char* s2) {
char *s3[1000];
int i = 0;
int por = 0;
char* povtor[1];
char* p;
p = strtok(s2, " ");
while (p != NULL) {
size_t len = strlen(p);
s3[i] = malloc(len + 1);
if (s3[i] == NULL) { perror("Out of memory"); exit(-1); }
strcpy(s3[i], p);
i++;
p = strtok(NULL, " ");
}
//тут подсчёт повторяющихся слов
}
int main(int argc, char* argv[])
{
char s1[1000];
int n;
setlocale(LC_ALL, "");
SetConsoleOutputCP(1251);
SetConsoleCP(1251);
printf("Введите количетсво строк: ");
scanf("%d", &n);
while (getchar() != '\n');
for (int i = 0; i < n; i++) {
printf("Введите строку: ");
gets(s1);
mindl(s1);
}
}
Как посчитать количество повторяющихся слов? Никак не могу придумать алгоритм.