提交时间:2025-12-19 15:25:32

运行 ID: 76550

#include <iostream> using namespace std; int main() { int weight; char urgent; cin >> weight >> urgent; int postage = 8; // 基础邮费 if (weight > 1000) { int excess = weight - 1000; // 超重的克数 // 步骤1:算能装满几个500克 int fullBags = excess / 500; // 比如200/500=0,600/500=1 // 步骤2:算有没有剩下的 int left = excess % 500; // 比如200%500=200,600%500=100 // 步骤3:如果有剩下的,多算1份 if (left > 0) { fullBags = fullBags + 1; // 比如200克→0+1=1份,600克→1+1=2份 } // 总超重费用 = 份数 × 4元 postage = postage + fullBags * 4; } // 加急费用 if (urgent == 'y') { postage = postage + 5; } cout << postage << endl; return 0; }