#include <stdio.h>
#include <stdlib.h>
#include <string>
typedef struct data{
float nilai;
char nama[20];
struct data *next;
}dataku;
int main (void){
dataku *data1, *data2, *temp, *data3;
data1 = (dataku *)malloc(sizeof(dataku));
data2 = (dataku *)malloc(sizeof(dataku));
strcpy(data1->nama, "Rio");
strcpy(data2->nama, "Izma");
data1->nilai=90;
data2->nilai=100;
data1->next=data2;
data2->next=NULL;
temp=data1;
for(;temp!=NULL; temp=temp->next)
{printf("%s, %0.0f", temp->nama, temp->nilai);
printf("\n");
}
data3 = (dataku *)malloc(sizeof(dataku));
strcpy(data3->nama, "Budi");
data3->nilai=80;
data1->next=data3;
data3->next=data2;
data2->next=NULL;
temp=data1;
for(;temp!=NULL; temp=temp->next)
{printf("%s, %0.0f", temp->nama, temp->nilai);
printf("\n");
}
system("pause");
return 0;
}
No comments:
Post a Comment