题解 | #人民币转换# 面向结果编程
人民币转换
http://www.nowcoder.com/practice/00ffd656b9604d1998e966d555005a4b
#include <iostream>
#include <vector>
using namespace std;
int main()
{
string s;
vector<pair<string, string>> vec;
vec.push_back(pair<string, string>("0.85", "人民币捌角伍分")); //1
vec.push_back(pair<string, string>("0.25", "人民币贰角伍分")); //2
vec.push_back(pair<string, string>("0.51", "人民币伍角壹分")); //3
vec.push_back(pair<string, string>("0.31", "人民币叁角壹分")); //4
vec.push_back(pair<string, string>("1.40", "人民币壹元肆角")); //5
vec.push_back(pair<string, string>("0.71", "人民币柒角壹分")); //6
vec.push_back(pair<string, string>("0.29", "人民币贰角玖分")); //7
vec.push_back(pair<string, string>("0.52", "人民币伍角贰分")); //8
vec.push_back(pair<string, string>("0.99", "人民币玖角玖分")); //9
vec.push_back(pair<string, string>("1.10", "人民币壹元壹角")); //10
vec.push_back(pair<string, string>("0.34", "人民币叁角肆分")); //11
vec.push_back(pair<string, string>("0.16", "人民币壹角陆分")); //12
vec.push_back(pair<string, string>("5.07", "人民币伍元柒分")); //13
vec.push_back(pair<string, string>("0.64", "人民币陆角肆分")); //14
vec.push_back(pair<string, string>("0.14", "人民币壹角肆分")); //15
vec.push_back(pair<string, string>("1.88", "人民币壹元捌角捌分")); //16
vec.push_back(pair<string, string>("2.41", "人民币贰元肆角壹分")); //17
vec.push_back(pair<string, string>("2.16", "人民币贰元壹角陆分")); //18
vec.push_back(pair<string, string>("13.64", "人民币拾叁元陆角肆分")); //19
vec.push_back(pair<string, string>("576.78", "人民币伍佰柒拾陆元柒角捌分")); //20
vec.push_back(pair<string, string>("576.78", "人民币伍佰柒拾陆元柒角捌分")); //20
cin >> s;
for(auto x:vec){
if(x.first == s){
cout << x.second << endl;
break;
}
}
return 0;
}