Run ID 作者 问题 语言 测评结果 Time Memory 代码长度 提交时间
108915 彭士宝 09优惠活动 C++ Compile Error 0 MS 0 KB 781 2025-01-23 16:05:34

Tests(0/0):


Code:

#include <iostream> #include <iomanip> // 用于设置输出格式 using namespace std; int main() { char membership; double price; // 读取会员类型和商品价格 cin >> membership >> price; // 根据会员类型计算应付金额 double discountRate; switch (membership) { case 'P': discountRate = 0.7; break; // 白金会员7折 case 'G': discountRate = 0.8; break; // 金卡会员8折 case 'S': discountRate = 0.9; break; // 银卡会员9折 default: discountRate = 0.95; break; // 普通客户9.5折 } // 计算应付金额并输出,保留两位小数 double payment = price * discount; cout << fixed << setprecision(2) << payment << endl; return 0; }


Run Info:

Main.cc: In function 'int main()':
Main.cc:22:30: error: 'discount' was not declared in this scope
     double payment = price * discount;
                              ^