码迷,mamicode.com
首页 > 编程语言 > 详细

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

时间:2014-11-24 18:55:19      阅读:191      评论:0      收藏:0      [点我收藏+]

标签:blog   io   ar   sp   on   div   log   bs   amp   

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; }

 

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

标签:blog   io   ar   sp   on   div   log   bs   amp   

原文地址:http://www.cnblogs.com/LegendLa/p/4103975.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!