#include "stdafx.h"
struct node {
int num;
struct node *next;
};
struct node * creat() {
struct node *head, *temp, *newp;
int n;
head = temp = NULL;
printf("Input Number:");
scanf("%d", &n);
while (n > 0) {
newp = (struct node *)malloc(sizeof(struct node));
newp->num = n;
newp->next = NULL;
if (head == NULL) {
head = temp = newp;
}
else {
temp->next = newp;
temp = newp;
}
printf("Input Number:");
scanf("%d", &n);
}
return head;
}
void show_node(struct node *head) {
struct node *temp = head;
while (temp != NULL) {
printf("%d", temp->num);
temp = temp->next;
}
}
int main() {
struct node *head;
head = creat();
show_node(head);
return 0;
}