gpt4 book ai didi

java - 这两种方法有什么区别? JAVA

转载 作者:行者123 更新时间:2023-11-29 07:06:03 25 4
gpt4 key购买 nike

我的教授为我提供了一堆方法来填写罗马数字程序(加法格式,所以 4=IIII,9=VIIII,等等)

我无法理解这两种方法之间的区别:

   **
* This method prints, to the standard output and in purely additive
* notation, the Roman numeral corresponding to a natural number.
* If the input value is 0, nothing is printed. This
* method must call the method romanDigitChar().
* @param val ?
*/

public void printRomanNumeral(int val)
{

}

**
* This method returns the Roman numeral digit corresponding
* to an integer value. You must use a nested-if statement.
* This method cannot perform any arithmetic operations.
* @param val ?
* @return ?
*/

public char romanDigitChar(int val)

{

}

romanDigitChar 是否应该逐位读取数字,并且一次只返回一位数字?如果是这样,我不明白 printRomanNumeral 将如何调用它。

我研究过其他罗马数字程序,但我似乎找不到任何使用其他方法调用的方法的方法,例如我可以与之比较的方法。

感谢任何建议!

最佳答案

我假设 romanDigitChar 为完全匹配的数字返回一个字符,例如仅限 1、5、10、50、100 等。 printRomanNumeral 会针对已知值作为数字重复调用此方法,以将它们转换为字符。我建议使用两个嵌套循环,一个用于具有递减值的特定字符的数量,一个用于提取每个值。内循环调用第二个方法。

我假设他/她需要 ASCII 字符,尽管罗马数字有特殊的 Unicode 字符。

关于java - 这两种方法有什么区别? JAVA,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19622510/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com