1008: 查询水果价格 Time Limit: 1 Sec Memory Limit: 128 MB 64bit IO Format: %lld Submitted: 202 Accepted: 80 [Submit][Status][Web Board] Description 已知四种水果(苹果、梨、桔子和葡萄,编号分别为1到4)的单价分别为3.00元/公斤、2.50元/公斤、4.10元/公斤、10.20元/公斤。 请设计程序根据用户输入的编号显示对应水果的单价。 Input 包含多组测试数据,每组测试数据占一行,包括一个整数代表水果的编号。 Output 每组测试数据输出占一行,具体格式详见样例。如果输入编号不在1到4的范围,直接输出价格为0。 Sample Input 3 1 2 0 4
Sample Output price = 4.10 price = 3.00 price = 2.50 price = 0.00 price = 10.20
#include<stdio.h> int main() { int a; while(scanf("%d",&a)!=EOF) { switch(a) { case 1: printf(“price = 3.00\n”); break; case 2: printf(“price = 2.50\n”); break; case 3: printf(“price = 4.10\n”); break; case 4: printf(“price = 10.20\n”); break; default: printf(“price = 0.00\n”); break; } } return 0; }