2224 - I2P(I)2020_Yang_HW12 Scoreboard

Time

2020/12/22 21:00:00 2020/12/29 18:00:00

Clarification

# Problem Asker Description Reply Replier Reply Time For all team

# Problem Pass Rate (passed user / total user)
11269 Text Editor
12577 Bank Data

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://www.dummies.com/programming/c/how-to-use-the-fgets-function-for-text-input-in-c-programming/)

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




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