#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; }
c语言编程练习题:7-55 查询水果价格
作者:yunjinqi
类别:编程
日期:2023-05-29 16:57:16
阅读:591 次
消耗积分:0 分
版权所有,转载本站文章请注明出处:云子量化, https://www.yunjinqi.top/article/180
最新文章
系统当前共有 405 篇文章