water || 算英文句子中单词个数

#include<stdio.h>
#include<iostream>
#include<math.h>
#include<string.h>
#include<vector>
#include<string>
using namespace std;
typedef long long ll;
char c[5000000];
int ans;
bool isapha(char x){
	if((x>='a'&&x<='z')||(x>='A'&&x<='Z'))return true;
	else return false;
}
int main(){
	while(cin.getline(c,5000000)){
		ans=0;
		bool f=0;
		for(int i=0;i<strlen(c);i++){
			if(isapha(c[i])&&f==0){
				ans++;
				f=1;
			}
			else if(!isapha(c[i])){
				f=0;
			}
		}
		cout<<ans<<endl;
	}
	
	return 0;
}

猜你喜欢

转载自blog.csdn.net/bekote/article/details/79721013