#include #include #include #include #include #include #include #include #include

<stdio.h> <conio.h> <string.h> <dos.h> <stdlib.h> <time.h> <math.h> <ctype.h> <graphics.h>

struct data { char nama[20]; struct data *prev; struct data *next; }*head=NULL,*tail=NULL,*pointer; void main() { char nama[20]; int cnt2,cnt=0; a: clrscr(); printf("masukkan nama:"); fflush(stdin); scanf("%[^\n]",nama); cnt++; if(strcmp(nama,"exit")==0) { exit(1); } pointer=(data*)malloc(sizeof(data)); strcpy(pointer->nama,nama); if(head==NULL) { pointer->prev=NULL; pointer->next=NULL; head=pointer; tail=pointer; } else { pointer->prev=NULL; //pointer->next=tail->prev; tail->prev=pointer->next; tail=pointer; } cnt2=cnt; int flag=0,cuz=0; pointer=head; do { if(flag==1) { if(cuz!=1)

{ pointer=tail; cuz=1; } else { } } printf("%s\n",pointer->nama); pointer=pointer->prev; flag=1; cnt2--; }while(pointer!=NULL); getch(); goto a; }

Sign up to vote on this title
UsefulNot useful