2232 - I2P(I)2020_Yang_lab12 Scoreboard

Time

2020/12/29 18:30:00 2020/12/29 20:30:00

Clarification

# Problem Asker Description Reply Replier Reply Time For all team

# Problem Pass Rate (passed user / total user)
12577 Bank Data
13089 Another text editor

12577 - Bank Data   

Description

One day, you are be assigned a task to write the program for bank. In this task, you are required to write two function below:

func1 : AccountData* createData(char* name, int money);

func2 : AccountData* userQuery(AccountData* data);

func1 help bank to store user's data and func2 help bank to return a copy data to user (In order to avoid user directly modify the money information in bank)

The bank give you a simple data struct to implement above two function.

typedef struct _AccountData {

    char* name;

    int money;

} AccountData;

main.c

function.h

note that: you can use strlen(const char* str) in string.h to get the length of string

hint: you should not directly assign name to data->name, you need  to malloc some memory space to copy the name's value.

data->name = name (x)

Input

S N M

S: the username  (2 < length(username) < 100)

N: the money in the bank

M: the number which user try to modify.

 

 

Output

Output the current money in the bank and other information. (if user try to modify the money in bank then output warning information otherwise output "query finish")

Sample Input  Download

Sample Output  Download

Partial Judge Code

12577.c

Partial Judge Header

12577.h

Tags




Discuss




13089 - Another text editor   

Description

In this problem, we simulate a simple text editor. Given a series of keyboard input texts and commands, output the final text content.

 

The text editing rules are defined as follows:

  • Five special commands started with a backslash (/) character:
    1. (/I): The editing-mode changing command, which switches the mode between INSERT and REPLACE.
      1. Initially, the editor is in the INSERT mode. Then a /I command changes the mode to REPLACE, the next /I command changes the mode back to INSERT, and so on.
      2. The INSERT mode: insert the text after the cursor.
      3. The REPLACE mode:
        1. If there is a character after the cursor and it is a newline character, ***insert the text before the newline character*** (this is what we have in the existing PC operation);
        2. Otherwise, use the text to replace the existing content after the cursor.
    2. (/R /L): The two navigating commands, which move the cursor to the right or to the left;
    3. (/B): The backspace command, which deletes a character (letter, digit or newline) before the cursor;
    4. (/n): The newline command, which creates a new line after the cursor.

 

  • Normal alphabetical/numerical and whitespace input (A-Za-z0-9 and ' '): directly writes (inserts or replaces) after the cursor of the text content.

 

The keyboard input sequence will not exceed 600 characters, and the text content of the testcases will also not exceed 600 characters when simulating.

 

Hint1:

#include <stdio.h>

#define MAX_SIZE 600

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

int main()
{

    fgets(input, MAX_SIZE, stdin);

    /* your code here */

    printf("%s", content);

    return 0;
}

Hint2:

Testcase1 contains /B+/L
Testcase2 contains /R+/L+/B
Testcase3 contains /R+/L+/B+/n
Testcase4 contains /n+/R+/L+/B+/I
Testcase5 contains /n+/R+/L+/B+/I

Input

The keyboard input sequence, which is only one line (i.e., without a newline character at the end).

There is always a valid command (/B /n /L /R /I) right after the backslash character.

Output

The final text content.

Sample Input  Download

Sample Output  Download

Tags




Discuss