二つのリンクリストを重複なしの一つのリンクリストに統一

#仕組みの説明
1)各リンクリストを作成する際、昇順として生成します。
2)どちらかのリストが空の場合、要素を持つリストのみをコピーする。
3)両方のリストが要素を持つ場合に、リスト1をリスト3にコピーした後に、リスト2とリスト3を比較し、リスト3が持ってないノードをコピーします。

```merge.c
#include <stdio.h>
#include <stdlib.h>

//node declaration
struct node{
  int data;
  struct node *link;
};

//function declaration
void add(struct node **, int);
void display(struct node *);
int count(struct node *);
void merge(struct node *, struct node *, struct node **);

void main(){
  struct node *first, *second, *third;
  
  first = second = third = NULL;
  
  add(&first,1);
  add(&first,2);
  add(&first,3);
  add(&first,4);
  add(&first,5);
  add(&first,6);
  add(&first,7);
  
  printf("First linked list:\n");
  display(first);
  printf("No. of elements in Linked List: %d\n",count(first));
  
  add(&second,8);
  add(&second,9);
  add(&second,3);
  add(&second,4);
  add(&second,5);
  add(&second,6);
  add(&second,7);
  
  printf("Second linked list:\n");
  display(second);
  printf("No. of elements in Linked List: %d\n",count(second));
  
  merge(first,second,&third);
  
  printf("The concatenated list:\n");
  display(third);
  printf("No. of elements in Linked List: %d\n",count(third));
  
}

//merge two list into one, excluding the same value node
void merge(struct node *q, struct node *r, struct node **s){
  struct node *temp, *t;
  int i;
  
  //if first and second list is empty, output message and return to main
  if(q == NULL && r == NULL){
    printf("The first and second list is empty, nothing to do.\n");
    return;
  }
  
  //set locator to non empty list. set locator to first list if both list is non empty.
  temp = (q == NULL ? r : q);
  
  //loop through non empty list
  while(temp != NULL){
    //copy non empty list to third list
    add(s,temp->data);
    //go to next node
    temp = temp->link;
  }
  
  //both list is non empty, copy second list to third list
  if((q != NULL) && (r != NULL)){
    //set locator to second list
    temp = r;
    
    //loop through second list
    while(temp != NULL){
      //set another locator to third list
      t = *s;
      
      //loop through third list
      while(t != NULL){
        //if third list has a node with the same value, do nothing and jump out of loop
        if(temp->data == t->data){
          break;
        }
        //go to next node
        t = t->link;
      }
      
      //if third list don't have a node with the same value, add to third list
      if(t == NULL){
        add(s, temp->data);
      }
      
      //go to next node
      temp = temp->link;
    }
  }

}

//add node to linked list by ascending order
void add(struct node **q, int num){
  struct node *r, *temp, *prev;
  
  //create new node
  r = malloc(sizeof(struct node));
  //set value
  r->data = num;
  
  //if list is empty or num is smaller than value of front node, add node at the front
  if((*q == NULL) || ((*q)->data > num)){
    //set link to null
    r->link = *q;
    *q = r;
  }else{
    //set locator to front of linked list
    temp = prev = *q;
    
    //loop until end of list
    while(temp != NULL){
      //check num against value of previous and current node
      if((prev->data <= num) && (num < temp->data)){
         //set link of new node to point to current
         r->link = temp;
         //set link of previous node to new node
         prev->link = r;
         return;
      }
      //keep current node address
      prev = temp;
      //go to next node
      temp = temp->link;
    }
    
    //if reached end of list
    if(temp == NULL){
      //set link of new node to null
      r->link = NULL;
      //set link of last node to point to new node
      prev->link = r;
    }

  }
  
}

//display node in linked list
void display(struct node *q){

  while(q!=NULL){
    printf("%d\n",q->data);
    q = q->link;
  }
}

//count number of node in linked list
int count(struct node *q){
  int c = 0;
  
  while(q!=NULL){
    c++;
    q = q->link;
  }
  
  return c;
}
```