解題思路
//羅馬數字一組字母代表一位數字
//一組又有分如【V】一個字母為一組以及如【IV】兩個字母為一組
//先設立可以兩個字母為一組的開頭字母如【I】【X】【C】
//再判斷只能單獨一個為一組的如【V】【L】【D】【M】
string rom[13] = { "M","CM","D","CD","C","XC","L","XL","X","IX","V","IV","I" };
int romnum[13] = { 1000,900,500,400,100,90,50,40,10,9,5,4,1 };
這邊是程式碼的GitHub鏈接(不要直接抄,反正格式也不對):
補發鏈接:
用函數會好看很多啦
我這邊給個想法而已啦XDDDD
覺得很醜的話就想辦法自己寫漂亮一點吧~
鏈接又失效啦!!!
補發新鏈接
新的鏈接: