/*
#include <stdio.h>
#include <stdlib.h>
int main()
{
printf("Hello world!\n");
return 0;
}
*/
#include <stdio.h>
#include <stdlib.h>
#include <malloc.h>
typedef struct _node
{
int data;
struct _node *next;
}Node;
int main(void)
{
Node *head=NULL;
Node *tail=NULL;
Node *cur=NULL;
Node *newNode=NULL;
int readData;
while(1)
{
scanf("%d", &readData);
if(readData<1){
break;
}
newNode=(Node*)malloc(sizeof(Node));
newNode->data=readData;
newNode->next=NULL;
if(head==NULL){
head=newNode;
}
else{
tail->next=newNode;
}
tail=newNode;
}
printf("\n");
if(head==NULL){
printf("---------------------------");
}
else{
cur=head;
printf("%d ",cur->data);
while(cur->next!=NULL){
cur=cur->next;
printf("%d ",cur->data);
}
}
printf("\n");
if(head==NULL){
return 0;
}
else {
Node* delNode=head;
Node*delNextNode=head->next;
printf("%d",head->data);
free(delNode);
while(delNextNode!=NULL)
{
delNode=delNextNode;
delNextNode=delNextNode->next;
printf("%d\n",delNode->data);
free(delNode);
}
}
return 0;
}
/*
#include<stdio.h>
int cpr(int *pArr) {
*pArr = 100;
}
int main() {
int a;
int *pA;
int arr[100]={10,20,30};
int *pArr = arr;
pA = &a;
printf("%p\n", &a);
printf("%p\n", pA);
printf("%p\n", &arr[0]);
printf("%p\n", arr);
printf("%d %d %d\n", *arr, *(arr+1), *arr+1);
cpr(pArr);
printf("%d %d %d\n", *arr, *(arr+1), *arr+1);
}
*/