Requirement: enter a string to count the number of words. Words are separated by spaces. Multiple spaces are allowed. Algorithm . Example: input: I love ChinaOutput:I:1Love:2China:1 First, we thought of a simulated method. We used
Emacs does not seem to provide a method for counting the number of words. Therefore, we need to use some extensions or elisp functions.
1) use external
Program To calculate
Set the following
Code Add it to the Emacs configuration file:
(Defun word-
This article describes how to count the number of words in a text file in python, and describes how to operate Python on text files and strings, for more information about how to count the number of words in a python text file, see the following
It is the number of times of swearing in each content, based on another array. there is no idea after writing it. how should we count it? the perfect solution can't be found out, after all, it is still slag.
Think of an ugly method, just look at it:
Counter is a class within the ColletionsCan be understood as a simple counter, you can count the number of characters appearing, examples are as followsImportCOLLECTIONSSTR1=['a','a','b','D']m=collections. Counter (STR1)Print(m) str2=['You're','Good'
Cycle-06. Count the number of words in a single line of text (15) time limit MS Memory limit 65536 KB code length limit 8000 B award Program StandardAuthor Zhang Tong Hongyu (Zhejiang University)This topic requires a program to count the number of
Source of the topic:Cycle-06. Count the number of words in a line of text (15) time limit MSMemory Limit 65536 KBCode length limit 8000 BProcedures for the award of questions StandardAuthor Zhang Tong Hongyu (Zhejiang University)This topic requires
05: count words, 05 count words05: count words
View
Submit
Statistics
Question
Total time limit:
1000 ms
Memory limit:
65536kB
Description
Common text editors have the word search function, which can
Combine a few main functions together:1. Read single words from text (remove spaces, special symbols, etc.)2. Use the words that are read to update the nodes of the binary tree (involving the construction of the two-fork tree, recursion)3. Middle
the perfect solution can't be figured out, after all, it's slag.
Think of a more ugly way to look at the line:
$str = "1111111111111112b22222222caonima22222222"; $words = [' 2b ', ' Caonima ']; $res = [];foreach ($words as $word) { $ res[$word]
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.