作者在 2020-11-21 11:56:41 发布以下内容
#include <stdio.h>
#include <string.h>
#include <ctype.h>
int main(void)
{
int ch=0;
int up=0,a=0,b=0;
int count=0,let=0;
double pj;
while((ch=getchar())!=EOF)
{
a=isalpha(up);
if(a)a=1;
b=isalpha(ch);
if(b){b=1;let++;}
if(a==0&&b==1)count++;
up=ch;
}
pj=(double)let/(double)(count);
printf("字母:%d个\n单词:%d个\n平均:%f个\n",let,count,pj);
return 0;
}
#include <string.h>
#include <ctype.h>
int main(void)
{
int ch=0;
int up=0,a=0,b=0;
int count=0,let=0;
double pj;
while((ch=getchar())!=EOF)
{
a=isalpha(up);
if(a)a=1;
b=isalpha(ch);
if(b){b=1;let++;}
if(a==0&&b==1)count++;
up=ch;
}
pj=(double)let/(double)(count);
printf("字母:%d个\n单词:%d个\n平均:%f个\n",let,count,pj);
return 0;
}