Im trying to create a roman numeral calculator and am unsure how I would parse a user input into 3 parts the first roman numeral the operator and the second numeral while ignoring any spaces the user might include for example XV + L the "XV" would be held by the left, the "+" would be held under op and the right would hold "L"
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
Use the indexof function to find instances of any operators you want to check for. Then take every character to the left of that index (using a substring), and assign it to one value. Take the character at the index and store that as the operator. Take everything that is left and store it as your second roman numeral.