Tek Yönlü Bağlantılı Liste Oluşturma

Tek Yönlü Bağlantılı Liste Oluşturma

  Bir çiçekçide satılan 3 tür çiçeğin günlük satış miktarları, 30 gün süre ile gün gün tek  yönlü bir listeye aktarılıyor. 
 a) Bu listeyi oluşturan, 
 b) İstenilen herhangi bir  gündeki en çok satılan çiçek türünü bulduran,
 b) ay sonunda her bir çiçekten kaç tane satıldığını hesaplatan,
 bir C++ programı yazınız.
#include  < stdio.h >
#include < stdlib.h >
#include < string.h >
 #include < conio.h >
  typedef struct cicek
    {int gun,c1,c2,c3;
    struct cicek *sonraki;
    } CICEK;
 
 
  typedef struct cicek CICEK;
  static CICEK  *bas; int t=0,t1=0,t2=0;
 
 
   CICEK *liste_olus()
  {CICEK *p;
   p=(CICEK *) malloc(sizeof(CICEK));
   p->sonraki=NULL;
   return p;
   }
 
 
 void eleman_ekle(CICEK *ct)
  {CICEK *p;
   if (bas== NULL) {bas=ct; return;}
   for (p=bas;p->sonraki!=NULL;p=p->sonraki);
   p->sonraki=ct;
   }
 
 
   void listele()
   {CICEK *p;
     for (p=bas;p!=NULL;p=p->sonraki)
  {printf("\\n gun=%d",p->gun);
  printf("\\n cicek1=%d",p->c1);
   printf("\\n cicek2=%d",p->c2);
   printf("\\n cicek3=%d",p->c3);
   }
     getchar;
     }
 
 
     void topla()
   {CICEK *p;
     for (p=bas;p!=NULL;p=p->sonraki)
  {printf("\\n gun=%d",p->gun);
  printf("\\n cicek1=%d",p->c1);
   printf("\\n cicek2=%d",p->c2);
   printf("\\n cicek3=%d",p->c3);
   t=t+p->c1;t1=t1+p->c2;t2=t2+p->c3;} printf("\\n %d",t);
   printf("\\n %d",t1);
   printf("\\n %d",t2);
     getchar;
     }
 
 
   CICEK *bul(int gun1)
     {CICEK *p;
       for (p=bas;p!= NULL;p=p->sonraki)
    if (p->gun==gun1)
    {if (((p->c1)>(p->c2)) && ((p->c1)>(p->c3))) printf("%d",p->c1);
     if ((p->c2>p->c1) && (p->c2 > p->c3)) printf("%d",p->c2);
     if ((p->c3>p->c1) && (p->c3 > p->c2)) printf("%d",p->c3);
      }
    return NULL;
    }
 
 
 main()
  {  CICEK *p,*m; int sec;
 
 
     do {printf("\\n 1. listeyi oluŸtur");
       printf("\\n 2. eleman ekle");
       printf("\\n 3. listele");
       printf("\\n 4. istenilen gündeki en çok çiçek satışını bul");
       printf("\\n 5. ay sonundaki 1.ci çiçek toplam satışı",t);
       printf("\\n 6. çıkış");
       printf("seciminiz");
       scanf("%d", &sec);
       switch (sec)
     {case 1:liste_olus();break;
     case 2:m=(CICEK *) malloc(sizeof(CICEK));
     m->sonraki=NULL;
     printf("gun");scanf("%d",&m->gun);
    printf("1. ‡i‡ek");scanf("%d",&m->c1);
    printf("2. ‡i‡ek");scanf("%d",&m->c2);
    printf("3. ‡i‡ek");scanf("%d",&m->c3);
    eleman_ekle(m);
    break;
     case 3:listele();  break;
     case 4:int gun1;
     printf("\\n listede aranacak gunu gir"); scanf("%d",&gun1);
     bul(gun1);
     break;
     case 5:topla(); break;
     case 6:exit(0);
 
 
     }
     }while(1);
     }

Yorumlar2

Levent Yangöz demiş ki;
11.01.2011

BUYUR ???


osman aziz tugay demiş ki;
10.01.2011

benim burda bulam imkanım olduğunu söyleyebilirim

 


Yorumlarınızı Bekliyoruz


Yorum Yazın

Yorum Yapın