#28469: 求解


1080294@dmhs.kh.edu.tw (cocodor)

學校 : 不指定學校
編號 : 177500
來源 : [101.9.174.233]
最後登入時間 :
2021-12-12 21:57:29
e972. 1. 貨幣轉換 (Currency) -- 2019年5月TOI練習賽新手組 | From: [101.9.174.233] | 發表日期 : 2021-12-12 13:45

#include<iostream>
#include<iomanip>
using namespace std;
int main(){
double a,b;
char c;
while(cin>>a>>b>>c){
if(c=='U'){
    if(a/30.9-b>=0)
    cout<<fixed<<setprecision(2)<<"U"<<" "<<a/30.9-b<<endl;
    else
    cout<<"No Money"<<endl;
}
if(c=='E'){
    if(a/34.5-b>=0)
    cout<<fixed<<setprecision(2)<<"E"<<" "<<(double)a/34.5-b<<endl;
    else
    cout<<"No Money"<<endl;
}
if(c=='J'){
    if(a/0.28-b>=0)
    cout<<fixed<<setprecision(2)<<"J"<<" "<<a/0.28-b<<endl;
    else
    cout<<"No Money"<<endl;
}
if(c=='T'){
    if(a-b>=0)
    cout<<fixed<<setprecision(2)<<"T"<<" "<<a-b<<endl;
    else
    cout<<"No Money"<<endl;
}
}
return 0;
}
老師說
少了0.00的呈現 <0 0.005~0之間 >=0.005 三個判斷
 
#28478: Re:求解


cges30901 (cges30901)

學校 : 不指定學校
編號 : 30877
來源 : [101.136.203.77]
最後登入時間 :
2024-04-07 15:34:14
e972. 1. 貨幣轉換 (Currency) -- 2019年5月TOI練習賽新手組 | From: [39.9.229.175] | 發表日期 : 2021-12-12 21:18

#include
#include
using namespace std;
int main(){
double a,b;
char c;
while(cin>>a>>b>>c){
if(c=='U'){
    if(a/30.9-b>=0)
    cout<<fixed<<setprecision(2)<<"U"<<" "<<a/30.9-b<<endl;
    else
    cout<<"No Money"<<endl;
}
if(c=='E'){
    if(a/34.5-b>=0)
    cout<<fixed<<setprecision(2)<<"E"<<" "<<(double)a/34.5-b<<endl;
    else
    cout<<"No Money"<<endl;
}
if(c=='J'){
    if(a/0.28-b>=0)
    cout<<fixed<<setprecision(2)<<"J"<<" "<<a/0.28-b<<endl;
    else
    cout<<"No Money"<<endl;
}
if(c=='T'){
    if(a-b>=0)
    cout<<fixed<<setprecision(2)<<"T"<<" "<<a-b<<endl;
    else
    cout<<"No Money"<<endl;
}
}
return 0;
}
老師說
少了0.00的呈現 =0.005 三個判斷


題目不就講得很清楚了?

「若餘額為正數且小於 0.05,列印 0.00」

 
ZeroJudge Forum