一、代码:
#include <stdio.h>
#include <stdlib.h>
#define _ULL unsigned long long
/*definition of single link:each node can only visit it's next node, and visit it's pre node,the last link point to NULL*/
/*use scene:sort number. get the minnest number from R[0]~R[n-1] and swap with R[0]; compare with other sort method*/
//Link is a struct which has a ull type and a Link * pointer type; mylink is a new name of struct Link by use of typedef
typedef struct Link
{
_ULL value;
struct Link *next;
}mylink;
/*
quantity: init a mylink which has quantity number; add by tail;
https://blog.csdn.net/qq_52607834/article/details/115922172
*/
mylink* init_mylink(_ULL quantity)
{
printf("begin to init...\n");
_ULL i = 0;
mylink* head_node = (mylink*)malloc(sizeof(mylink)); //init a head node
head_node->value=0;
printf("in init_mylink, i:%d\n", i);
mylink* p_cursor_node = head_node; //a cursor pointer point to head_node
for(i = 1; i < quantity; i ++)
{
/*
create a new pointer and point it to an assigned value
each tmp_mylink has two addresses: an address of itself + an address point to other link node
*/
mylink* tmp_mylink = (mylink*)malloc(sizeof(mylink)); //malloc a new pointer
tmp_mylink->value = i; //value assignment
tmp_mylink->next = NULL; /