1876 - I2P(I)2019_Yang_EECS_hw13 Scoreboard

Time

2019/12/17 21:00:00 2019/12/24 18:00:00

Clarification

# Problem Asker Description Reply Replier Reply Time For all team

# Problem Pass Rate (passed user / total user)
11269 Text Editor
12533 Distance on 2D plane

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




12533 - Distance on 2D plane   

Description

In this problem, you are forced to use structure to record imformation and use afterward.

You will be given several points' locations on 2D plane(x, y), and you should compute the Euclidean distance of specific two points.

(Hint: you can use sqrt() to calculate the square root)

 

You should implement funcion.c below and submit it. (Due to Partial judge)

#include <stdio.h>
#include <math.h>
#include "function.h"

Point * ones_vec_1(int length)
{
   /// Please implement
   /// 1. Malloc memory for point array
   /// 2. Read values into point array
   /// 3. Return the address of the first element in the array

}

float compute_distance(Point* a, int first_id, int second_id)
{
    float ans;
    Point first_p, second_p;

    /// Please implement
    /// 1. Get two point from function argument
    /// 2. Compute 2D distance and return ans

    return ans;
}

 

You should see .c and .h file below to know how the function and the whole program works

Input

Input may have several lines.

The first line contains an integer M, indicating how many points' locations you should read.

(Notice that the first point is indexed 0, and the second point is indexed 1, and so on...)

And the next M lines , each line has two integers, indicating point's location x and y.

 

The next line contains an integer N, indicating the number of the pairs of chosen two points.

And the next N lines, each line contains two integers, which are two indices representing two specific points needed to be calculated for Euclidean distance.

Output

Ouput has N lines.

Each line contains a floating number, indicating the Euclidan distance of two specific points.

Sample Input  Download

Sample Output  Download

Partial Judge Code

12533.c

Partial Judge Header

12533.h

Tags




Discuss