2452 - I2P(I)2021_Yang_hw12 Scoreboard

Time

2021/12/21 20:30:00 2021/12/28 18:00:00

Clarification

# Problem Asker Description Reply Replier Reply Time For all team

# Problem Pass Rate (passed user / total user)
11269 Text Editor
12507 Searching Remark

11269 - Text Editor   

Description

In this problem we simulate a simple text editor. Given a series of keyboard input, output the final text content.
The text editing rules are defined as following:
1. Normal alphabetical input and whitespace input (abcdefg…. and ‘ ‘) directly write  after the cursor of the text content.
And four special commands started with a backslash(/) character
2. The backspace command which deletes a letter before the cursor (/backspace)
3. The newline command which creates a new line after the cursor (/newline)
4. The two navigating commands which move the cursor (/left /right)

The size of the text content is fixed to 500 characters, and the text content of testcases will not exceed 500 characters when simulating.

Use fgets(). (https://docs.microsoft.com/en-us/cpp/c-runtime-library/reference/fgets-fgetws?view=msvc-170)

Hint:

#include <stdio.h>

#define MAX_SIZE 500

char content[MAX_SIZE];
char input[MAX_SIZE];

int main()
{

    fgets(input, MAX_SIZE, stdin);

    /* your code here */

    printf("%s", content);

    return 0;
}

Input

The keyboard input sequence.
There is always a valid command(/backspace /newline /left /right) right after the backslash character.
There is no newline character at the end

Output

The final text content.

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://docs.microsoft.com/en-us/cpp/c-runtime-library/reference/fgets-fgetws?view=msvc-170)

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