简单的输入输出,看代码即可
struct tree
{
int var;
struct tree* next;
};
#define NULL 0
int main()
{
int n,i;
struct tree* head = (struct tree *)malloc(sizeof(struct tree));
struct tree* tmp;
struct tree* tail;
scanf("%d\n", &n);
int* a = (int *)malloc(sizeof(int)*n);
int* b = (int *)malloc(sizeof(int)*n);
for(i=0; i<n; i++)
{
scanf("%d",&a[i]);
}
for(i=0; i<n; i++)
{
scanf("%d",&b[i]);
b[i] += a[i];
}
head->var = b[0];
head->next = NULL;
tail = head;
for(i=1; i<n; i++)
{
tmp = (struct tree *)malloc(sizeof(struct tree));
tmp->var = b[i];
tmp->next = NULL;
tail->next = tmp;
tail = tail->next;
}
while(head != NULL)
{
printf("%d ", head->var);
head = head->next;
}
return 0;
}