输入一行字符,分别统计出其中英文字母,空格,数字字符,其它字符及单词的个数.
来源:学生作业帮 编辑:作业帮 分类:综合作业 时间:2024/05/10 08:39:39
输入一行字符,分别统计出其中英文字母,空格,数字字符,其它字符及单词的个数.
//C语言代码:
#include <stdio.h>
int main()
{
char c;
int letters = 0, space = 0, digit = 0,others = 0,words = 0;
bool flag;
printf("请输入一行字符:");
while((c = getchar()) != '\n')
{
if(c >= 'a' && c <= 'z' || c >= 'A' && c <= 'Z')
letters++;
else if(c == ' ')
space++;
else if(c >= '0' && c <= '9')
digit++;
else
others++;
if( c == ' ')
flag = false;
else if(flag == false)
{
flag = true;
words++;
}
}
printf("字母数:%d\n空格数:%d\n数字数:%d\n其它字符:%d\n单词数:%d\n",letters,space,digit,others,words);
}
#include <stdio.h>
int main()
{
char c;
int letters = 0, space = 0, digit = 0,others = 0,words = 0;
bool flag;
printf("请输入一行字符:");
while((c = getchar()) != '\n')
{
if(c >= 'a' && c <= 'z' || c >= 'A' && c <= 'Z')
letters++;
else if(c == ' ')
space++;
else if(c >= '0' && c <= '9')
digit++;
else
others++;
if( c == ' ')
flag = false;
else if(flag == false)
{
flag = true;
words++;
}
}
printf("字母数:%d\n空格数:%d\n数字数:%d\n其它字符:%d\n单词数:%d\n",letters,space,digit,others,words);
}
输入一行字符,分别统计出其中英文字母,空格,数字字符,其它字符及单词的个数.
输入一行字符,分别统计出其中英文字母、空格、数字和其它字符的个数
c++输入一行字符,分别统计出其中英文字母,空格,数字字符和其它字符的个数.
用C语言编程:输入一行字符,分别统计出其中英文字母、空格、数字和其他字符的个数.
输入一行字符,分别统计出其中英文字母(包括大小写)、空格、数字和其他字符的个数.
输入一行字符,分别统计出其中大小写英文字母、空格、数字和其他字母的个数
超简单C语言填空题输入一行字符,分别统计出其中英文字母、空格、数字和其它字符的个数.程序分析:利用while语句,条件为
C语言:输入一行字符,分别统计出其中的大写英文字母、小写英文字母、数字和其他字符的个数
输入一行字符,分别统计出其中英文字母、空格
分别用C语言指针和函数:输入一行字符,分别统计出其中英文字母,空格,数字和其他字符的个数
用C语言编写一段程序,输入一行字符,分别统计出其中的英文字母、空格、数字和其他字符的个数.
一道C语言题目.输入一行字符,分别统计出其中英文字母,空格,数字和其他字符的个数.#includeint main(){