三九宝宝网宝宝教育写作范文

1输入一行字符分别统计出其中英文字母空格数字和其他字符的

01月03日 编辑 39baobao.com

[C输入一个字符串统计出某个指定的字符在该字符串中出现的次]#include<iostream> #include<string> using namespace std; void main() { char *p,a[81]; int n,i; cout<&lt;"请输入一个字符串:"<<endl; cin.getline(a,81); char search; c...+阅读

#include

int main(int argc, char *argv[])

{

int i[4]={0,0,0,0};

char a;

while((a=getchar())!='\n')

{

if(a>='0'&a<='9') i[0]++;//数字

else if((a>='a'&a<='z')||(a>='A'&a<='Z')) i[1]++;//字母

else if(a==' ') i[2]++;//空格

else i[3]++;//其他字符

}

printf("您输入的数字有%d个\n"

"您输入的字母有%d个\n"

"您输入的空格有%d个\n"

"您输入的其它字符有%d个\n",i[0],i[1],i[2],i[3]);

return 0;

}

以下为关联文档:

pascal怎么统计出字符数量如果你的字符全是在一行的话,可以用一个string类型读进来,然后用length函数统计,代码如下(从1.txt读入,输出到屏幕): program 1; var s:string; begin assign(input,'1.txt'); rese...

字符串统计的算法有代码更好谢啦参考网上的代码用C#写的:调试成功,你先琢磨琢磨: using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace 求字符串重复 { // 有...

考研英语大作文格式开头用空格需要空格的。 作文书写时还要注意词与词之间要保持一定的距离,不能紧靠在一起。字母之间的连写也应该按照习惯,不能随意乱来。防止字母或跳上跳下,或一律写成同一高度,占上中两...

C语言中的分类统计各个字符#include<iostream> using namespace std; char Change(char c); int IsLetter(char c); int main() { int n=0; static int a[27]; char str[100]; cout<&lt;"请输入字符串:"<<...

c语言统计字符个数#include <stdlib.h> #include <stdio.h> int main(void) { char input; int daxie = 0, xiaoxie = 0, kongge = 0, number = 0, others = 0, count = 0; while((input=getc...

c语言字符分类统计#include #include void main() { char c[100]; int i,n,ch=0,blank=0,number=0,other=0; printf("Input something:\n"); gets(c); n=strlen(c); for(i=0;i{ if((c[i]>='a' &...

分类统计字符 C语言例:使用while语句循环统计 : #include<stdio.h> int main() { char c; int letters_num = 0, space_num = 0, digit_num = 0, other_num = 0; while ((c = getchar()) != '\n'...

c语言中怎么统计字符数组中每个字符的个数#include <stdio.h> #include <ctype.h> // isalpha, isdigit int main() //求数组中的各种字符的个数 { char ch[200]; int i; int n=0, // 字母 k=0, // 数字 j=0; // 其他 sc...

C语言统计字符个数问题两处错误: 1. 算符优先级: while(c=getchar()!='\n') 改成: while((c=getchar())!='\n') 2.拼写错误: if((c>='A')&(c<='z')||(c>='a')&(c<='z')) 改成: if((c>='A')&(c<='Z'...

推荐阅读
图文推荐