題目連結: https://zerojudge.tw/ShowProblem?problemid=d430
# 解題思路
只要輸入進來的字是有字母的或有數字的,就可以直接算一個字,接著繼續算就行了
# 程式碼
#include <bits/stdc++.h> | |
using namespace std; | |
int main() { | |
ios_base::sync_with_stdio(false); | |
cout.tie(0),cin.tie(0); | |
string s; | |
int ans=0; | |
while(cin>>s){ | |
for(int i=0;i<s.length();i++){ | |
if(s[i]>='A'&&s[i]<='Z'||s[i]>='a'&&s[i]<='z'||s[i]>='0'&&s[i]<='9'){ans++;break;} | |
} | |
} | |
cout<<ans; | |
} |