题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2017
//C++代码
#include<iostream>
#include<cstring>
#include<cctype>
using namespace std;
int main(){
int n,i,ans;
char a[1000];
cin>>n;
while(n--){
cin>>a;
for(ans=0,i=0;i<strlen(a);i++){
if(isdigit(a[i])) ans++;
}
cout<<ans<<endl;
}
return 0;
}
本文提供了一个使用C++解决HDU 2017题目(http://acm.hdu.edu.cn/showproblem.php?pid=2017)的方法。该方法通过读取输入字符串并遍历字符,统计并输出字符串中所有数字字符的数量。
212

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



