第十三周项目五 字符串操作(1)

来源:互联网 发布:openwrt p2p端口 编辑:程序博客网 时间:2024/05/17 02:07

统计字母‘A’出现的次数。

#include <iostream>#include <cstdio>using namespace std;int main(){    char str[50];    int i=0,n=0;    cout<<"输出字符串:"<<endl;    gets(str);    while (str[i]!='\0')    {        if (str[i]=='A') n++;        i++;    }    cout<<"其中'A'的个数是:"<<n<<endl;    return 0;}


0 0