#45777: C++解答


sun20100627 (胡桃我婆)

學校 : 新北市私立竹林高級中學
編號 : 223865
來源 : [163.20.230.241]
最後登入時間 :
2025-04-29 13:01:13
e972. 1. 貨幣轉換 (Currency) -- 2019年5月TOI練習賽新手組 | From: [163.20.230.241] | 發表日期 : 2025-04-11 15:41

#include <iostream>
#include <iomanip>
using namespace std;

int main() {
  int n,m;
  char MONEY;
  cin >> n;
  cin >> m >> MONEY;
  if(MONEY == 'T'){
    double money = (n - m * 1) / 1;
    if(money < 0) cout << "No Money" << endl;
    else if(money < 0.05) cout << "T " << "0.00" << endl; 
    else cout << fixed  <<  setprecision(2) <<"T " << money << endl;
  }
  else if(MONEY == 'J'){
    double money = (n - m * 0.28) / 0.28;
    if(money < 0) cout << "No Money" << endl;
    else if(money < 0.05) cout << "J " << "0.00" << endl;
    else cout << fixed  <<  setprecision(2) << "J " << money << endl;
  }
  else if(MONEY == 'U'){
    double money = (n - m * 30.9) / 30.9;
    if(money < 0) cout << "No Money" << endl;
    else if(money < 0.05) cout << "U " << "0.00" << endl;
    else cout << fixed  <<  setprecision(2) << "U " << money << endl;
  }
  else if(MONEY == 'E'){
    double money = (n - m * 34.5) / 34.5;
    if(money < 0) cout << "No Money" << endl;
    else if(money < 0.05) cout << "E " << "0.00" << endl;
    else cout << fixed  <<  setprecision(2) << "E " << money << endl;
  }

  
  return 0;
}

 
ZeroJudge Forum