2018年7月23日 星期一

itsa [C_AR10-中]新通話費率

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

void replaceD(string &s)
{
int i = 0;
while (i < s.length())
{
if (s[i] == ',')
s[i] = ' ';
i++;
}
}

int main()
{
int month = 0, second = 0;
double cost = 0;
string s;
getline(cin, s);
replaceD(s);
stringstream ss(s);
ss >> month >> second;
if (month == 186)
{
cost = second * 0.09;
if (cost <= month)
cost = month;
else if (cost <= month * 2)
cost *= 0.9;
else
cost *= 0.8;
}
else if (month == 386)
{
cost = second * 0.08;
if (cost <= month)
cost = month;
else if (cost <= month * 2)
cost *= 0.8;
else
cost *= 0.7;
}
else if (month == 586)
{
cost = second * 0.07;
if (cost <= month)
cost = month;
else if (cost <= month * 2)
cost *= 0.7;
else
cost *= 0.6;
}
else
{
cost = second * 0.06;
if (cost <= month)
cost = month;
else if (cost <= month * 2)
cost *= 0.6;
else
cost *= 0.5;
}
cout << fixed << setprecision(0) << cost << endl;
return 0;
}

沒有留言:

張貼留言