Level 4: Statistics of the number of characters in a string ------- C language programming technology (cyclic structure programming 1)

 Level 4: Statistics of the number of characters in a string ------- C language programming technology (cyclic structure programming 1)

#include<stdio.h>
	int main(void)
	{  
	  /*********Begin*********/
	  char str[81];
	  int i,letter=0,dight=0,space=0,other=0;
	  gets(str);//输入一个字符串
	  for(i=0;str[i]!='\0';i++)//扫描字符串的每一个数组
	  if(str[i]>='A'&&str[i]<='Z'||str[i]>='a'&&str[i]<='z')
	  letter++;//字母个数统计
	  else if(str[i]>='0'&&str[i]<='9')
	  dight++;//数字统计
	  else if(str[i]==' ')
	  space++;
	  else
	  other++;
	  printf("%d %d %d %d",letter,dight,space,other);
	  /*********End**********/ 
       return 0;
	}

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=324128375&siteId=291194637