[2021-03-22]字符串练习

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#include<iostream>
#include<string>
using namespace std;
int main()
{
string s;
int cnt=0;
getline(cin,s);
int len=s.length();
for(int i=0;i<len;i++)
{
if(s[i]>='0'&&s[i]<='9'||s[i]>='a'&&s[i]<='z'||s[i]>='A'&&s[i]<='Z')
cnt++;
}
cout<<cnt;
return 0;
}