/
*copyright (c)2014,烟台大学计算机学院
*All rights reserved
*文件名称:123.cpp
*作者:孙春红
*完成日期:2014年11月23日
*版本号:v1.0
*
*问题描述:阅读程序,完成字符的统计功能。
*输入描述:输入字符串。
*程序输出:输出符合要求字符的个数。
*/
#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]>='0'&&str[i]<='9') n++;
i++;
}
cout<<"其中的数字个数是: "<<n<<endl;
return 0;
}
运行结果:
知识点总结:
运用数组以及前面所学的知识完成数字的统计。
学习心得:
条件的运用和理解很重要。

被折叠的 条评论
为什么被折叠?



