第十三周项目5——统计大、小写字母的个数

来源:互联网 发布:linux 多进程 例子 编辑:程序博客网 时间:2024/06/01 07:49
/*
 *Copyright(c)2014,烟台大学计算机学院
 *All rights reserved.
 *文件名称:test.cpp
 *作者:李晓凯
 *完成日期:2014年 11月 30日
 *版本号:v1.0
 *
 *问题描述:统计大、小写字母的个数
 *程序输入:一个字符串
 *程序输出:大、小写字母的个数

 */

#include <iostream>#include <cstdio>using namespace std;int main(){    char str[50];    int i,r,t;    i=r=t=0;    cout<<"输入字符串:"<<endl;    gets(str);    do    {        if(str[i]>='a'&&str[i]<='z')            r++;        if(str[i]>='A'&&str[i]<='Z')            t++;        i++;    }while(str[i]!='\0');    cout << "其中小写字母的个数:" <<r<<endl<<"其中大写字母的个数:"<<t<< endl;    return 0;}



0 0
原创粉丝点击