可读性,当我插入单词、字母和句子时,为什么 Coleman-Liau 索引公式不起作用?

问题描述

我的代码有什么问题?这是不起作用的部分

float L = (letters / words) * 100; and float S = (sentences / words) * 100;

当我将字母、单词和句子插入公式时,它给出了错误的答案。

#include <stdio.h>
#include <string.h>
#include <cs50.h>
#include <ctype.h>
#include <math.h>

int main(void)
{
char ch[500];

int i;
int ii; 
int iii;

int LettersWspace = 0;
int letters = 0;
int words = 1;
int sentences = 0;
int index;



string text = get_string("Enter Text: ");

 for(i = 0; text[i] != '\0'; i++)
 {
LettersWspace++;
 }
for( i = 0; i < LettersWspace; i++)
 {
if (text[i] == 32)
    letters++;
  }
  letters = LettersWspace - letters;

  ii = 0;
{
  if (text[ii] == ' ')
{
    words++;
}
ii++;
}

while (ii <= text[ii]);
   

iii = 0;
do
    {
if (text[iii] == '?' || text[iii] == '!' || text[iii] == '.')
{
    sentences++;
}
iii++;
}

while (iii <= text[iii]);

float L = (letters / words) * 100;

float S = (sentences / words) * 100;

return (index = 0.0588 * L - 0.296 * S - 15.8);


printf("%i\n",(int) sentences);

return 0;

    }

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)