1867 - I2P(I)2019_Yang_EECS_hw12 Scoreboard

Time

2019/12/10 21:00:00 2019/12/17 12:00:00

Clarification

# Problem Asker Description Reply Replier Reply Time For all team

# Problem Pass Rate (passed user / total user)
11275 Sentence Reversal
12507 Searching Remark

11275 - Sentence Reversal   

Description

In this problem, you are given several sentences, and you have to print the reversal of each of them.

A reversal of a sentence is the reversed order of words in the original sentence. For example, for the input string "this is a book", the result should be "book a is this".

Hint 1: we suggest you to do the task by a recursive function. The function seeks the first word from current location, and call itself recursively. Before each return, the function will print the word it found. Then all words will be printed in the reversed order.

The function prototype is something like this:

    void sentence_reversal( char *now ) ;    // which seek the first word from *now, and pass an new *now location to the called function

And the recursion is like the following figure:

this       (4th printed word)
    -> is      (3rd printed word)
        -> a       (2nd printed word)
            -> book  (1st printed word)

Hint 2: Print the spaces between words, and there should be no blanks (spaces) at the begin or the end of new sentences. If the original sentence has only one word, print the word directly without any spaces.

Note: Another method to solve this problem is seeking words from the end of the original sentence. But we strongly recommend you to try the recursive way as a practice.

Hint 3: Use fgets(). (https://www.dummies.com/programming/c/how-to-use-the-fgets-function-for-text-input-in-c-programming/)

Input

There are several lines of input, and each line presents a sentence.

No lines are longer than 500 characters, and there will be no empty lines. At most 10 sentences will appear in a test case.

Words in sentences are separated by a space (' '). There will be no continuous spaces, or any spaces at the beginning or end of the sentences.

Output

Print out each reversal sentence. All words in a reversal sentence are separated by a space, and there is a '\n' at the end of each line.

Sample Input  Download

Sample Output  Download

Tags




Discuss




12507 - Searching Remark   

Description

You are going to design a searching engine on finding articles. User will enter some key words, and then the engine will find the most suitable article based on the key words.

(The picture is just for reference.  You are not going to implement a google.)

How suitable is an article regarding the key word? The searching engine will scan through the article, and count how many remarks there are in the article for a key word. The rule for remark is listed as below:

  • A key word only contains upper case and lower case English alphabets.

  • Words in the article are separated by the following separator symbols : white space' ', new line character '\n', hyphen '-', slash '/', colon ':', brackets '(', ')', '[', ']', comma ',', and period '.'.

  • An remark is counted if the key words matches a word in the article under case-insensitive matching. For example, "apple" and "AppLE" are considered a match.

Given a key word and an article, please output the number of remark in the article.

Explanation for sample IO

The words in the article are separated by separator symbols, and every word in the article is highlighted in the picture.

The key word is "ms", and there are two remarks in the article (highlighted in the picture below), and thus output "2". (Note that matching is case-insensitive, so "ms" is considered a match to "MS".)

Hints:

1. Use strtok(). (https://www.tutorialspoint.com/c_standard_library/c_function_strtok.htm)

2. Use fgets(). (https://www.dummies.com/programming/c/how-to-use-the-fgets-function-for-text-input-in-c-programming/)

Input

The first line contains a string K, begin the key word.

After that, there are several lines, being the content of the article, ended with EOF (end of file).

It is guaranteed that :

  • K is consist of [a-zA-Z] only, and length of K <= 20

  • The article in test case is extracted from a paper submitted to IEEE Transactions on Mobile Computing journal. The link will be available after the lab is over. Only English alphabets, numbers, and the separator symbols mentioned above will appear in the test case.

Output

Output the number of remark. Remember to add a new line character in the end.

Sample Input  Download

Sample Output  Download

Tags




Discuss