[Buổi 21][Xử lý chuỗi][Lab] Bài 1: Tokenization


LÀM BÀI

Points: 100
Time limit: 1.0s
Memory limit: 256M

Author:
Problem types
Allowed languages
C++

Tokenization

Bối cảnh

Một dòng văn bản cần được tách thành các token theo whitespace.

Whitespace liên tiếp không tạo token rỗng.

Yêu cầu

  1. Đọc cả dòng.
  2. Dùng stringstream tách token.
  3. In số token, sau đó mỗi token trên một dòng.

Input

Một dòng.

Output

Dòng đầu là số token; các dòng sau là token theo thứ tự.

Ràng buộc

0 ≤ |line| ≤ 2000.

Ví dụ 1

Input

C++ Foundation Fullhouse Dev

Output

4
C++
Foundation
Fullhouse
Dev

Giải thích

Có 4 token: C++, Foundation, Fullhouse, Dev.

Ví dụ 2

Input

one   two  three

Output

3
one
two
three

Giải thích

Whitespace đầu/cuối và liên tiếp bị stringstream bỏ qua, còn 3 token.

Thông tin học tập

  • Module: M06
  • Buổi: B21
  • Loại bài: LAB
  • Độ khó: Easy
  • Concepts: stringstream, tokenization, vector, whitespace
  • Giới hạn kiến thức: B01-B21
  • Time limit: 1 second(s)
  • Memory limit: 256 MB
  • Point: 100

Comments

There are no comments at the moment.

Zalo