/*
*Copyright (c) 2013 ,烟台大学计算机学院
*All rights reserved.
*作者:张凤宁
*完成日期:2013年12月11
*版本号:v1.0
*问题描述:统计大/小写字母出现的个数
*样例输入:
*样例输出:
*问题分析:用简单的方法,学会活学活用
*/
#include<iostream>
#include<cstdio>
using namespace std;
int main()
{
char str[50];
int i=0,n=0,m=0;
cout<<"输入字符串:";
gets(str);
while(str[i]!='\0')
{
if(str[i]>='A'&&str[i]<='Z') m++;
else if(str[i]>='a'&&str[i]<='z') n++;
i++;
}
cout<<"其中大写字母出现的个数是: "<<m<<endl;
cout<<"其中小写字母出现的个数是: "<<n<<endl;
return 0;
}
运行结果: