2176 - IP_2020_YOU_LAB7 Scoreboard

Time

2020/11/17 15:30:00 2020/11/17 18:00:00

Clarification

# Problem Asker Description Reply Replier Reply Time For all team

# Problem Pass Rate (passed user / total user)
12996 Reversi
12997 Two Singly Linked List Comparison

12996 - Reversi   

Description

“黑白棋”是一種雙人對弈的棋類遊戲。棋盤共有8行8列共64格。開局時,棋盤正中央的4格先置放黑白相隔的4枚棋子。雙方輪流落子。只要落子和棋盤上任一枚己方的棋子在一條線上(橫、直、斜線皆可)夾著對方棋子,就能將對方的這些棋子轉變為我己方。不能在不能夾住對手的任一顆棋子的地方落子。遊戲在雙方都不能再落子,或棋盤已無空格的情況下結束,子多的一方勝。

給定一個棋局,以及黑方或白方下一個落子的位置,請試著模擬出落子後棋局的變化。

 

Note:

  1. 利用字元 ‘_’ 來代表棋盤中的空格
  2. 利用字元 ‘x’ 來代表棋盤中的黑子
  3. 利用字元 ‘o’ 來代表棋盤中的白子
  4. 字元之間存在著空格將其分開

舉例:

- 給定的棋局範例

_ _ _ _ _ _ _ _

_ _ _ _ _ _ _ _

_ _ _ _ _ _ _ _

_ _ _ o x _ _ _

_ _ _ x x x _ _

_ _ _ _ x o _ _

_ _ _ _ _ _ _ _

_ _ _ _ _ _ _ _

 

- 白子落在(5, 3)後的棋局變化

_ _ _ _ _ _ _ _

_ _ _ _ _ _ _ _

_ _ _ _ _ _ _ _

_ _ _ o x _ _ _

_ _ _ o x x _ _

_ _ _ o o o _ _

_ _ _ _ _ _ _ _

_ _ _ _ _ _ _ _

Input

一個棋局;一個字元用來表示現在是黑方或白方落子;兩個整數用來表示落子的位置。

 

Note:

  1. ‘x’ 表示現在為黑方落子;‘o’ 表示現在為白方落子
  2. 測資中不會出現不合遊戲規則的落子位置

Output

落子後的棋局

輸出比須符合以下格式:

c c c c c c c c

c c c c c c c c

c c c c c c c c

c c c c c c c c

c c c c c c c c

c c c c c c c c

c c c c c c c c

c c c c c c c c

 

Note:

  1. 輸出的最後必須要有一個換行符號 ('\n')
  2. 字元 c‘_’‘x’‘o’ 中一種

Sample Input  Download

Sample Output  Download

Tags




Discuss




12997 - Two Singly Linked List Comparison   

Description

Given two linked lists. Please Write a C program to compare the data in the nodes of the linked lists to check if they are equal.

 

function.c

#include "function.h"
 
/************************ Node ************************/
Node *create_node(int data)
{
    Node *node = (Node *)malloc(sizeof(Node));
    node->data = data;
    node->next = NULL;
 
    return node;
}
 
/************************ SLL ************************/
SinglyLinkedList *create_singlyLinkedList()
{
    SinglyLinkedList *list = (SinglyLinkedList *)malloc(sizeof(SinglyLinkedList));
    list->head = NULL;
    list->tail = NULL;
 
    int len;
    scanf("%d", &len);
    for (int i = 0i < leni++)
    {
        int data;
        scanf("%d", &data);
        insert_node(listdata);
    }
 
    return list;
}
 
void insert_node(SinglyLinkedList *listint data)
{
    Node *node = create_node(data);
 
    if (list->head == NULL)
    {
        list->head = node;
    }
    else
    {
        list->tail->next = node;
    }
 
    list->tail = node;
}
 
void print_list(SinglyLinkedList *list)
{
    if (list->head == NULL)
    {
        printf("Nothing in the linked list.\n");
        return;
    }
 
    Node *tmp = list->head;
    for (; tmp != list->tailtmp = tmp->next)
    {
        printf("%d "tmp->data);
    }
    printf("%d\n"list->tail->data);
}
 
void free_list(SinglyLinkedList *list)
{
    Node *node = list->head;
    while (node)
    {
        Node *tmp = node;
        node = node->next;
        free(tmp);
    }
}
 
// Complete the compare_lists function below.
int compare_lists(SinglyLinkedList *list1SinglyLinkedList *list2)
{
    Node *tmp1 = list1->head;
    Node *tmp2 = list2->head;
 
    /* Todo */
}

Input

Input follows below format:

len1

n1 n2 n3 n4 ….

len2

m1 m2 m3 m4 ….

 

Note:

  1. All len1len2n1~ and m1~ are integers. len1 represents the length of the first linked list, also indicates the total number of the data in the next line.
  2. 32767 >= len1, len2 >= 0.
  3. 32767 >= n1~, m1~ >= -32768.

 

Example:

3

1 2 3

4

1 2 3 4

 

List1: 1 -> 2 -> 3 -> NULL

List2: 1 -> 2 -> 3 -> 4 -> NULL

 

These two lists have equal data attributes for the first nodes, List2 is longer, though, these lists are not equal.

 

Output

Output should follow below format:

1(0)

Note:

  1. Need to have a return value('\n') at the end of your string.
  2. If two lists are equal, print (“1\n”); otherwise, print(“0\n”).

Sample Input  Download

Sample Output  Download

Partial Judge Code

12997.c

Partial Judge Header

12997.h

Tags




Discuss