Linklist 1701293010 Michael Wijaya
Posted March 13th, 2014 by michaelwijaya96#include <stdio.h>
#include <stdlib.h>
struct node{
int x;
struct node*next;
};
int main(){
struct node *root;
struct node *conductor;
int flag = 0;
root = (struct node*)malloc(sizeof(struct node));
root->next=0;
do{
printf(“Masukkan angka [1…100] :”);
scanf(“%d”,&root->x);fflush(stdin);
}while(root->x<0||root->x>100);
flag++;
while(flag<=10){
system(“cls”);
conductor=root;
printf(“%d”,conductor->x);
while(conductor->next!=0){
conductor=conductor->next;
printf(“->%d”,conductor->x);
}
if(flag==10)
{
break;
}
conductor->next=(struct node*)malloc(sizeof(struct node));
conductor=conductor->next;
conductor->next=0;
printf(“\n”);
do{
printf(“Masukkan angka [1…100] :”);
scanf(“%d”,&conductor->x);fflush(stdin);
}while(conductor->x<0||conductor->x>100);
flag++;
}
getchar();
return 0;
}
Leave a Reply