Я пробовал все, но не могу определить ошибку в моем коде.
Получение ввода пользователя и подсчет букв
int main(void)
{
int letters = 0;
//Getting user input
string text = get_string("Text: ");
//Counting the letters
for (int i = 0; i < strlen(text); i++)
{
if (isalpha(text[i]))
{
letters++;
}
}
подсчет слов и предложений
int words = 1;
//Checking the spaces and counting the words
for (int i = 1; i < strlen(text); i++)
{
if ((isspace(text[i])) && (isalpha(text[i+1])) )
{
words++;
}
}
int sentences = 0;
//Checking the symbols and counting the sentences
for (int i = 0; i < strlen(text); i++)
{
if (text[i] == '.' || text[i] == '!' || text[i] == '?')
{
sentences++;
}
}
А затем применяя формулу
double L = 100.0 * letters / words;
double S = 100.0 * sentences / words;
double index = 0.0588 * L - 0.296 * S - 15.8;
int trueIndex = round(index);
if (trueIndex >= 1 && trueIndex <= 16)
{
printf("Grade %i\n", trueIndex);
}
else
{
if (trueIndex < 1)
{
printf("Before Grade 1\n");
}
if (trueIndex > 16)
{
printf("Grade 16+\n");
}
}
}
Это дает мне такую ошибку: ожидалось «Оценка 8 \ n», а не «Оценка 9 \ n ". Я знаю, что это как-то связано с тем, как я обращался с поплавками, но не понимаю, в чем дело