1378 - I2P CS 2017 Fall Lab6 Makeup Scoreboard

Time

2018/01/11 09:00:00 2018/01/11 11:30:00

Clarification

# Problem Asker Description Reply Replier Reply Time For all team

# Problem Pass Rate (passed user / total user)
10922 Insertion Sort
11751 Sorting makes me happy
11794 Delete Last Node

10922 - Insertion Sort   

Description

實作插入排序法讓一個序列的數字遞增,並輸出數字總共交換了幾次。

比如說一個序列1 3 7 9 2,前四個數字都已經排好了,這時候第五個數字2進來,他必須跟9,7,3交換使得序列變成1 2 3 7 9。這個數字2的交換次數就是3次。

Input

輸入第一行為一個數字T,代表測試資料的筆數。接下來有T筆測資,每筆測資第一行為一個正整數N,表示這筆測資有N個數字。每筆測資的第二行會有N個數字,每個數字間以空格隔開。

數字範圍:

0 < N <= 100

0 <= 序列內的數字 <= 1000000

Output

輸出一行數字,將每筆測資的答案加總後輸出。

Sample Input  Download

Sample Output  Download

Tags

韩永楷老师数据结构mooc MOOC



Discuss




11751 - Sorting makes me happy   

Description

On the Wednesday morning in week 15, TA remembers that HT gives students a homework, which is related to quick sorting with struct.

Now, TA wants to examine that whether you did the homework.

 

We will give you a list of objects, each has three attributes: a int number, a string, and a float number

And you should sort them according to int number first, and then string, and then float number.

(All in the descending order. For example: int number 3 is behind 4 in output list)

(For example: string annie is behind string apple in output list) 

 

HINT: If you don't understand the meaning of the problem after reading above, please see the sample IO and think clearly :) 

 

 

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

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "function.h"
 
int compare_function(const void* a, const void* b)
{
 
// set appropriate type
 
// first sorted by value
 
// if equal then soreted by str
 
// if still equal then sorted by x
 
}

 

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

Input

Input will contain four lines.

First line contains N,  indicating the number of objects you should read.

The following three lines contain each object's three attributes: a int number, a string, and a float number.

( 0 < N < 100, 0 < len(string) < 30)

Output

Output contain N lines. (And you should printf "\n" in the end)

You should show the sorted objects in each line in descending order.

Sample Input  Download

Sample Output  Download

Partial Judge Code

11751.c

Partial Judge Header

11751.h

Tags




Discuss




11794 - Delete Last Node   

Description

In this problem, you are asked to implement 4 functions:

1. void Create_List(Node**, int);

This function is used to create the linked list according to the input.

2. Node* Delete_Last_Node(Node*);

This function is used to find the last node of the linked list, and delete it.

We have to return the processed linked list.

3. void Print_List(Node*);

This function is used to print out the key value in the linked list.

4. void Free_List(Node*);

This function is used to free the memory space.

Input

The input contains one line of several integers.

The line represents a linked list, and each integer is a node of the linked list.

Each line of input is ended by -1, and you don't need to add a new node with key value -1.

It is guaranteed that:

  • Each key value in the node is an integer between 0 and 1000.
  • Each linked list has less than 1000 nodes, and at last 2 nodes

Output

You need to output the linked list which has been through the deletion of the last node.

Each key value is separated by "->".

Sample Input  Download

Sample Output  Download

Partial Judge Code

11794.c

Partial Judge Header

11794.h

Tags




Discuss