# 水果计费系统

<p>本关任务&#xff1a;编写程序&#xff0c;有五种水果&#xff0c;apple、banana、orage、strawberry、pear&#xff0c;每一种有一个价格&#xff08;浮点小数&#xff09;&#xff0c;由老板输入&#xff0c;请提示用户选择什么水果&#xff0c;购买数量&#xff08;按照斤两&#xff09;&#xff0c;然后将总价显示出来。</p>

以下程序实现了这一功能，请你填补空白处内容：

```cpp
#include<stdio.h>
int main(){
	typedef enum {apple, banana, orange, strawberry, pear} fruits;
	double prices[5];			 
	fruits purchase;			 
	int fruit;				   
	double amount;			   
	for(int i = 0; i < 5; i++)
		scanf("%lf", &prices[i]);
	printf("水果编号：1.苹果  2.香蕉  3.橘子  4.草莓  5.梨\n");
	printf("请输入购买的水果(1~5)，以及购买数量（按照斤两）：\n");
	scanf("%d %lf", &fruit, &amount);
	purchase = (fruits)fruit;	 
	
	________________________;

	return 0; 
}
```

## template

```cpp
#include<stdio.h>
int main(){
	typedef enum {apple, banana, orange, strawberry, pear} fruits;
	double prices[5];			 
	fruits purchase;			 
	int fruit;				   
	double amount;			   
	for(int i = 0; i < 5; i++)
		scanf("%lf", &prices[i]);
	printf("水果编号：1.苹果  2.香蕉  3.橘子  4.草莓  5.梨\n");
	printf("请输入购买的水果(1~5)，以及购买数量（按照斤两）：\n");
	scanf("%d %lf", &fruit, &amount);
	purchase = (fruits)fruit;	 
	printf("总价为：%.3lf", prices[purchase-1]*amount);
	return 0; 
}
```

## 答案

```cpp
printf("总价为：%.3lf", prices[purchase-1]*amount);
```

## 选项

### A

```cpp
printf("总价为：%.3lf", prices[purchase]*amount);
```

### B

```cpp
printf("总价为：%.3lf", prices(purchase-1)*amount);
```

### C

```cpp
printf("总价为：%.3lf", prices(purchase)*amount);
```