【正文】
Color Rate Amount\n)。 for(i=0。iSIZE。i++) { printf(%12s,flower[i].name)。 switch(flower[i].color) { case red: printf(%8s,red)。 break。 case white: printf(%8s,white)。 break。 case yellow: printf(%8s,yellow)。 break。 case purple: printf(%8s,purple)。 break。 case orange: printf(%8s,orange)。 break。 } printf(%%10d\n,flower[i].rate,flower[i].amount)。 }}/*詢問用戶購買的鮮花的種類和株的數(shù)量,計(jì)算總的價(jià)格的函數(shù)定義*/float buy(FLOWER flower[]){ int i。 char name[20]。 COLOR color。 float rate,price。 int amount,flag。 printf(\nPlease enter name and rate you want to buy:\n)。 /*輸出需要的鮮花的名字和價(jià)格*/scanf(%s%f,name,amp。rate)。 flag=1。 while(flag) /*客戶購買花的情況*/ { printf(0red\t1white\t2yellow\t3purple\t4orante\n)。 printf(Please choose a color:\n)。 scanf(%d,amp。color)。 if(color=0amp。amp。color=4) flag=0。 else printf(Not have this color\n)。 } printf(Please amount you want to buy:\n)。 /*輸出需要的花的數(shù)量*/scanf(%d,amp。amount)。 for(i=0。iSIZE。i++) { if(flower[i].rate==rateamp。amp。strcmp(flower[i].name,name)==0amp。amp。flower[i].color==color) break。 } if(i==SIZE) { printf(\nNot fount the flower you buy\n)。 /*沒有要買的花*/price=0。 } else if(flower[i].amountamount)/*所購花數(shù)量不夠*/ { printf(\nAmount not enough