1 条题解
-
0
先用正常思路打一遍
#include<bits/stdc++.h> using namespace std; string s; int main(){ cin>>s; int cnt=0; for(unsigned int i=0;i<s.length();i++){ cnt+=(isdigit(s[i])); } cout<<cnt; return 0; }此时我们会发现
AC:0 WA:2
所以 我们得学一种新的写法:
getline(cin,a)这就是读入字符串并且忽略空格结束读入的写法AC code
#include<bits/stdc++.h> using namespace std; string s; int main(){ getline(cin,s); int cnt=0; for(unsigned int i=0;i<s.length();i++){ cnt+=(isdigit(s[i])); } cout<<cnt; return 0; }
- 1
信息
- ID
- 163
- 时间
- 1000ms
- 内存
- 128MiB
- 难度
- 10
- 标签
- 递交数
- 2
- 已通过
- 1
- 上传者