对C语言我是个菜鸟,所以希望编写的清晰点,我的邮箱是184653796@hstc.edu.cn 谢谢啦
统计字母,意思就是看当前的字符ASCII码是否介于A—Z或a—z之间;
统计单词,意思就是看当前的字符ASCII码是否为空格,因为空格意味着单词的结束;
统计句子,意思就是看当前的字符ASCII码是否为句号;
ASCII码表如下:
http://www.360doc.com/content/10/0914/12/3357352_53546956.shtml
统计单词,意思就是看当前的字符ASCII码是否为空格,因为空格意味着单词的结束;
统计句子,意思就是看当前的字符ASCII码是否为句号;
ASCII码表如下:
http://www.360doc.com/content/10/0914/12/3357352_53546956.shtml
温馨提示:答案为网友推荐,仅供参考
第1个回答 2010-11-07
#include <stdio.h>
void main()
{
char c;
int abc=0;
int num=0;
int space=0;
int other=0;
while((c=getchar())!='\n')
{
if((c>='a'&&c<='z')||(c>='A'&&c<='Z'))
abc++;
else if((c>='0')&&(c<='9'))
num++;
else if(c==' ')
space++;
else
other++;
}
printf("abc=%d\nnum=%d\nspace=%d\nother=%d\n",abc,num,space,other);
}
void main()
{
char c;
int abc=0;
int num=0;
int space=0;
int other=0;
while((c=getchar())!='\n')
{
if((c>='a'&&c<='z')||(c>='A'&&c<='Z'))
abc++;
else if((c>='0')&&(c<='9'))
num++;
else if(c==' ')
space++;
else
other++;
}
printf("abc=%d\nnum=%d\nspace=%d\nother=%d\n",abc,num,space,other);
}