13699 - EE2310_Lab_8_2   

Description

/*  Please follow our exact rules otherwise you WILL LOSE POINTS */

 

#include <stdio.h>
#include <stdlib.h>

/* DO NOT CHANGE STRUCT */
struct node{
    int data;
    struct node *next;
};
typedef struct node node_t;

typedef struct linked_list{
    node_t *head;
    node_t *tail;
} linked_list_t;

void output_list(linked_list_t *ptr_list){
/* your code here
 *
 */
}

void add_node(linked_list_t *list_ptr, int data){
/* your code here
 *
 */

}

 

/* DO NOT CHANGE MAIN */

int main(){
    linked_list_t my_list;
    my_list.head = NULL;
    my_list.tail = NULL;
    int data, input_size;
    /* when you add a node, you add it at the tail */
    
    scanf("%d\n", &input_size);
    for(int i=0; i < input_size; ++i){
        scanf("%d", &data);
        add_node(&my_list, data);
    }
    
    output_list(&my_list);
    
    return 0;
}

 

Input

5
5 4 7 2 9

 

Output

5 4 7 2 9

 

Sample Input  Download

Sample Output  Download

Tags




Discuss