Mar 13
#include <stdio.h>
#include <stdlib.h>
struct node
{
int x;
struct node *tail;
}*head, *arrow;
void main()
{
int input=1;
head=(struct node*)malloc(sizeof(struct node));
head->tail=0;
arrow=head;
do
{
printf(“Masukkan Angka ke-%d [1..10] : “, input);
scanf(“%d”, &head->x);
fflush(stdin);
}
while (head->x<0 || head->x>10);
for(int input=2;input<=5;input++)
{
arrow->tail=(struct node*)malloc(sizeof(struct node));
arrow=arrow->tail;
printf(“Masukkan Angka ke-%d : “, input);
scanf(“%d”, &arrow->x); fflush(stdin);
arrow->tail=0;
}
arrow=head;
do
{
printf(“%d”, arrow->x);
arrow=arrow->tail;
if (arrow->tail!=0)
{
printf(” -> “);
}
else
{
printf(” -> %d”, arrow->x);
}
}while (arrow->tail!=0);
getchar();
}
Recent Comments