Я сейчас пишу код для моей курсовой работы, который анализирует вставленный вручную текст. Я должен найти общее количество непробельных символов и общее количество слов. Кроме того, я должен найти любые повторяющиеся слова в строке, а затем отобразить их с количеством повторений. Я застрял в поиске повторяющихся слов и отображении количества повторений. Кроме того, мое знание C ограничено, с темами, которые я знаю, включая указатели, строки, файлы и функции, циклы, если условия и т. Д. c ... Ниже приведен мой код:
#include <stdio.h>
int num, numi, text, length, length1, word;
numi = 0;
word = 1;
int main()
{
char text[] = "Dennis MacAlistair Ritchie (September 9, 1941 - October 12, 2011) was an American computer scientist. He created the C programming language and, with long-time colleague Ken Thompson, the Unix operating system and B programming language. Dennis Ritchie was born in Bronxville, New York. His father was Alistair E. Ritchie, a long-time Bell Labs scientist and co-author of The Design of Switching Circuits on switching circuit theory. As a child, Dennis moved with his family to Summit, New Jersey, where he graduated from Summit High School. He graduated from Harvard University with degrees in physics and applied mathematics.";
printf("Welcome to UNM Text Editor. Your original text is:\n\n");
printf("%s", text);
length = strlen(text);
for (numi=0; numi<=length; numi++)
{
if (text[numi] == ' ')
{
length1++;
if (text[numi + 1] != ' ')
{
word++;
}
}
}
printf("\n\nThe total number of characters (without spaces) is: %d", length-length1);
printf("\nThe total number of words is: %d", word);
}