第13周项目5(1-2)-字符串操作

来源:互联网 发布:企业数据管理软件 编辑:程序博客网 时间:2024/05/20 20:39
/* *Copyright (c) 2014, 烟台大学计算机学院 *All rights reserved. *文件名称:week13-project5-1-2.cpp *作者:高赞 *完成日期:2014年 11 月 22 日 *版本号: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') n++;        if(str[i]>='a'&&str[i]<='z') m++;        i++;    }    cout<< "其中大写字母的个数是: " << n << endl        << "小写字母的个数是:" << m << endl ;    return 0;}

0 0
原创粉丝点击