统计字母'A'和 数字 出现的次数;

/*
* 程序的版权和版本声明部分
* Copyright (c)2012, 烟台大学计算机学院学生
* All rightsreserved.
* 文件名称: x.cpp
* 作者:徐本锡
* 完成日期: 2012年 12 月 13 日
* 版本号: v1.0
* 输入描述:

  * 问题描述: 
  .统计字母'A'和 数字 出现的次数;
  
	
	  * 程序输出:
	  
*/
//我的代码:
#include <iostream>
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')
			++n;
		if(str[i]>='0'&&str[i]<='9')
			m++;
		i++;
	}
	cout<<"其中的数字个数是: "<<m<<endl;
	cout<<"其中“A”出现的次数:"<<n<<endl;
	return 0;
}


统计字母'A'和 数字 出现的次数;_第1张图片

 

你可能感兴趣的:(统计字母'A'和 数字 出现的次数;)