设计一个类Solution,其中包含一个成员函数count_digits,其功能是统计传入的string类型参数中数字字符的个数并返回。

裁判测试员样例

#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <cctype>
#include <string>
#include <iostream>
using namespace std;

/* 请在这里填写答案 */

int main()
{
   int t;

   cin >> t;
   getchar();
   while (t--)
   {
       string str;
       Solution obj;

       getline(cin,str);
       int digits = obj.count_digits(str);

       cout << digits << endl;
   }

   return 0;
}

输入样例:

2
asdfasdf123123asdfasdf
asdf111111111asdfasdfasdf

输出样例:

6
9


  • 就几件    2020-06-15 11:42:21
  • 阅读 1538    收藏 0    回答 1
  • 邀请
  • 收藏
  • 分享
发送
登录 后发表评论
  • 51testing软件测试圈微信