My Carelessness

Back to your page!


Or leave your comments here.

RegendLa

导航

计算机算法-C语言-统计字母数字个数解

Question:输入一串以“?”结尾的字符,分别统计其中字母数字的个数,输出字母及数字的个数。

Solve:

#include<stdio.h>
#include<stdlib.h>
int main()
{
	char c;
	int m=0;//字母个数 
	int n=0;//数字个数 
	scanf("%c",&c);
	while(c!='?')
	{
		if(c>='A'&&c<='Z'||c>='a'&&c<='z')  
            m++; if(c>='0'&&c<='9')  
            n++; scanf("%c",&c); } printf("字母个数=%d\n数字个数=%d\n",m,n); return 0; }

 

posted on 2014-11-24 17:48  最爱七  阅读(1197)  评论(0编辑  收藏  举报




Thanks for your coming!
If what you read helps,I would appreciate!