64,654
社区成员
发帖
与我相关
我的任务
分享
#include<iostream>
#include<string>
#include<vector>
#include<cctype>
using namespace std;
int main()
{
vector<string> str;
string s;
int a;
cin >> a;
for (int i = 0; i < a; ++i) {
cin >> s;
str.push_back(s);
}
size_t cnt = 0 ;
for (size_t ix = 0; ix != str.size(); ++ix) {
for (size_t jx = 0; jx != str[ix].size(); ++jx) {
if (isdigit(str[ix][jx]))
++cnt;
}
cout << cnt << endl;
cnt = 0;
}
return 0;
}
#include<iostream>
#include<string>
#include<vector>
#include<cctype>
using namespace std;
int main()
{
vector<string> str;
string s;
int a;
cin>>a;
for(int i=0;i<a;++i)
{
cin>>s;
str.push_back(s);
}
string::size_type jx;
for(vector<string>::size_type ix = 0; ix != str.size(); ++ix)
{
string::size_type count = 0;
for(jx=0;jx!=str[ix].size();++jx)
{
if(isdigit(str[ix][jx]))
++count;
}
cout<<count<<endl;
}
return 0;
}