问题及代码
/*
*ALL rights reserved.
*文件名称:shisanzhouxiangmu5(2)
*作者:李长鸿
*完成时间:2014.11.24
*问题描述:统计A出现的次数
*/
#include<iostream>
#include<cstdio>
using namespace std;
int main()
{
char str[50];
int i=0,n=0;
cout<<"输入字符串:";
gets(str);
while(str[i]!='\0')
{
if(str[i]=='A') n++;
i++;
}
cout<<"其中的字母'A'的个数是: "<<n<<endl;
return 0;
}