作者:yunjinqi 类别:
日期:2023-05-29 16:57:16
阅读:450 次 消耗积分:0 分
#include <stdio.h>
int main(){
int count=0;
int n=0;
double prices[5] = {0,3.00,2.50,4.10,10.20};
char names[][7] = {"exit","apple","pear","orange","grape"};
int sequences[5] = {1,2,3,4,0};
int i;
int r=0;
char *s;
// 输出编号和名字
for (i=0;i<5;i++){
r = sequences[i];
s = names[r];
printf("[%d] %s\n",r,s);
}
// 保存查询的num
//while (scanf("%d",&n)!=EOF && count<5){
while (scanf("%d", &n) != EOF) {
if (count>=5){break;}
if (n==0){break;}
//printf("n=%d %.2f\n",n, prices[n]);
//if (n>4){printf("price = 0.00\n");}
//if (n<0){printf("price = 0.00\n");}
if (n<=4 && n>0){printf("price = %.2f\n",prices[n]);}
else{printf("price = 0.00\n");}
count++;
}
return 0;
}