编写程序计算句子的平均词长
请输入一个句子:It was deja vu all over again.平均长度为:3.4
#include<stdio.h> int main() { char* s="It was deja vu all over again"; char*p=s; int count=0; int slen=0; for(;*p!='\0';p++,slen++) if(*p==' ') count++; printf("原始句子是 :%s\n该句子长度是%d 共包含%d个单词 平均单词长度是%lf\n",s,slen,count+1,1.0*(slen-count)/(count+1)); return 0; }