欢迎来|

EricFirst001

园龄:1年8个月粉丝:2关注:2

单词统计

单词统计

单词统计 | SDUT

#include <stdio.h>
#include <string.h>
int main(){
	char a[100];
	int count=0;
	int flag=0;
	gets(a);
	for(int i=0;i<strlen(a);i++){
		if(a[i]==' '){
			flag=0;//将flag一直更新只要等于空格就一直赋值为0。
		}
		else if(flag==0){
			flag=1;
			count++;//单词更新且改变flag
		}
	}
	printf("%d\n",count);
	return 0;
}

本文作者:EricFirst001

本文链接:https://www.cnblogs.com/cuers/p/17563329.html

版权声明:本作品采用知识共享署名-非商业性使用-禁止演绎 2.5 中国大陆许可协议进行许可。

posted @   EricFirst001  阅读(2)  评论(0编辑  收藏  举报
点击右上角即可分享
微信分享提示
评论
收藏
关注
推荐
深色
回顶
收起