c是链表
#include <stdio.h>
#include <stdlib.h>
struct _node
{
int data;
struct _node *next;
};
typedef struct _node list;
void main()
{
int i, n, input_data;
list *h, *now_node, *next_node;
printf("Enter num n:");
scanf("%d", &n);
h = (list*) malloc(sizeof(list));
h->data = -1;
h->next = NULL;
for(i = 0; i<n; i++)
{
scanf("%d", &input_data);
if(i == 0)
{
h->data = input_data;
now_node = h;
}else{
next_node = (list*) malloc(sizeof(list));
next_node->data = input_data;
now_node->next = next_node;
now_node = next_node;
}
}
//打印
now_node = h;
while(now_node != NULL)
{
printf("%d",now_node->data);
now_node = now_node->next;
}
return 1;
}