ZCMU 1544: Counting Words

Description

DongDong prefers English words to English sentences, so he wants to count the words of a sentence. Could you help him?

Input

The first line contains a positive integer T (T<=1000), which means T test cases. Then comes T lines, each line contains a string which combines with several words separated by spaces. Note that there may be more than one space to separate two words.

Output

For each test case, please print the number of words of the sentence.

Sample Input

3 Every night in my dreams I see you I feel you That is how I know you go on

Sample Output

5 6 8
#include<string.h>
int main() {
	int T;
	scanf("%d",&T);
	getchar();
	while(T--){
		char a[1000];
		gets(a);
		int i;
		int num=0;
		for(i=1;i<strlen(a);i++){
			if(a[i-1]==' '&&a[i]!=' '){
				num=num+1;
			}
		}
		if(a[0]!=' ')num++;
		printf("%d\n",num);
	} 
}

相关推荐

  1. ZCMU 1544: Counting Words

    2024-03-27 09:08:02       20 阅读
  2. ZCMU 1510: Love Letter

    2024-03-27 09:08:02       59 阅读
  3. ZCMU 1531: 序列的混乱程度

    2024-03-27 09:08:02       18 阅读
  4. LeetCode第1544题 - 整理字符串

    2024-03-27 09:08:02       30 阅读
  5. 【Leetcode】【2024048】1544. Make The String Great

    2024-03-27 09:08:02       14 阅读
  6. Acwing154滑动窗口

    2024-03-27 09:08:02       35 阅读

最近更新

  1. 前端导出pdf

    2024-03-27 09:08:02       0 阅读
  2. Knife4j的原理及应用详解(五)

    2024-03-27 09:08:02       0 阅读
  3. Day2--每日一练

    2024-03-27 09:08:02       0 阅读
  4. 东方博宜1626 - 暑假的旅游计划

    2024-03-27 09:08:02       0 阅读
  5. react小白面试不得不会的20个问题——第二篇

    2024-03-27 09:08:02       0 阅读
  6. 简单滤波算法伪码

    2024-03-27 09:08:02       0 阅读
  7. Mongodb索引简介

    2024-03-27 09:08:02       0 阅读
  8. Linux 6种日志查看方法

    2024-03-27 09:08:02       0 阅读
  9. 案例研究(Case Study)是什么?怎么写?

    2024-03-27 09:08:02       0 阅读
  10. Linux虚拟化技术:从Xen到KVM

    2024-03-27 09:08:02       0 阅读

热门阅读

  1. 运行conda activate报错,有关提示运行conda init...

    2024-03-27 09:08:02       18 阅读
  2. 网络原理讲解

    2024-03-27 09:08:02       20 阅读
  3. 3.26总结

    2024-03-27 09:08:02       18 阅读
  4. 3月26日ACwing每日一题

    2024-03-27 09:08:02       16 阅读
  5. spring boot3登录开发(整合jwt)

    2024-03-27 09:08:02       16 阅读
  6. 【Python笔记-FastAPI】定时任务实现(APScheduler)

    2024-03-27 09:08:02       19 阅读
  7. .net core 将html 转为图片

    2024-03-27 09:08:02       18 阅读
  8. 使用 PointNet 和 PyTorch3D 进行点云分类

    2024-03-27 09:08:02       19 阅读