求一C语言难题的源代码(朋友们救我!)

来源:百度知道 编辑:UC知道 时间:2024/05/09 20:16:52
原题:
一个产品有两个版本,A版¥3.5,B版¥5.5。编一个程序,提示用户输入产品版本与数量,据此计算并输出价格。
要用枚举!!!!程序勿简化!!!!!
谢谢。。。。。。。。。

#include <stdio.h>
#include <stdlib.h>

enum product{A,B};

void main()
{
product shuru;
char c;
int n;
float price;
const float A_price=3.5,B_price=5.5;
printf("请输入产品版本:");
scanf("%c",&c);
if(c=='A'||c=='a')shuru=A;
else if(c=='B'||c=='b')shuru=B;
else
{
printf("非法输入\n");
exit(0);
}
printf("请输入要购买该产品的数量:");
scanf("%d",&n);
if(shuru==A)price=A_price*n;
else price=B_price*n;
printf("总价格是:%.1f\n",price);
}

#include <stdio.h>
typdef enum{
A = 65,
B,
}my_type;

int main()
{
double price[2] = {4.5, 5.5}, tmp = 0;
my_type tp;
printf("Please input the type and count\n");
scanf("%c%d", &tp, &tmp);
tmp = price[