/*
烟台大学计算机学院
作者:任子仪
日期:2013年12月2日
问题描述:统计字符串中的大小写字母个数
样例输入:
样例输出:
问题分析:
*/
#include<iostream>
#include<cstdio>
using namespace std;
int main()
{
char str[50];
int i=0,n=0,z=0;
cout<<"输入字符串:";
gets(str);
while(str[i]!='\0')
{
//输出大写字母的个数
if(str[i]>=65&&str[i]<=90) n++;
//输出小写字母的个数
if(str[i]>=97&&str[i]<=122) z++;
i++;
}
cout<<"其中的大写字母个数是: "<<n<<endl;
cout<<"其中的小写字母个数是: "<<z<<endl;
return 0;
}
示例图片:
心得体会:。。。。。。。。。。