Stack Data Structure C Main Program Version 1.0


  1. //      main.c
  2. //      
  3. //      Copyright 2010 Hafizh Herdi Naufal <twohnuvo@gmail.com>
  4. //      
  5. //      This program is free software; you can redistribute it and/or modify
  6. //      it under the terms of the GNU General Public License as published by
  7. //      the Free Software Foundation; either version 2 of the License, or
  8. //      (at your option) any later version.
  9. //      
  10. //      This program is distributed in the hope that it will be useful,
  11. //      but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. //      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13. //      GNU General Public License for more details.
  14. //      
  15. //      You should have received a copy of the GNU General Public License
  16. //      along with this program; if not, write to the Free Software
  17. //      Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
  18. //      MA 02110-1301, USA.
  19.  
  20.  
  21. #include "inpost.h"
  22. #include "inpost.c"
  23. int main()
  24. {
  25.     Stack S,T;
  26.     infotype a,b;
  27.     int i;
  28.     boolean k;
  29.     adrStack n=nil;
  30.    
  31.     createStack(&S);
  32.     createStack(&T);
  33.     k = isEmpty(&S);
  34.     if(k)
  35.     {
  36.         printf("Stack masih kosong");
  37.     }
  38.     for (i=0; i<5; i++)
  39.     {
  40.         a = inputS();
  41.         push(&S, a);
  42.     }
  43.     printf("Puncak saat ini : %d \n", S.top->info);
  44.     popWithNotice(&S,&n);
  45.     printf("Puncak menjadi : %d\n", S.top->info);
  46.     printStack(S);
  47.     printf("\nMasukkan elemen yang ingin dicari : ");
  48.     scanf("%d",&b);
  49.     searchElmt(&S,b);
  50.     getchar();
  51.     printStack(S);
  52.     printf("\nPuncak saat ini : %d \n", S.top->info);
  53.     getchar();
  54.     printf("Urutan Stack Dibalik : \n");
  55.     T=reverseStack(&S);
  56.     printStack(T);
  57.     return 0;
  58.  
  59. }
  60.  

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s