gpt4 book ai didi

Java编码转换为伪代码

转载 作者:行者123 更新时间:2023-11-29 04:57:48 24 4
gpt4 key购买 nike

我必须将此 Java 代码转换为伪代码。该程序接受 2 次并以分钟为单位返回时间跨度。

在 Java 中我们有 int hr1_intint hr2_int 那么它们在伪代码中是什么?而 String 、 sub-string 、 parseInt 、 try-catch 结构也将是什么伪装的?

try
{
hr1_int = Integer.parseInt(hr1);
min1_int = Integer.parseInt(min1);

}
catch(NumberFormatException e)
{
System.out.println("The input time is wrong. Please reinput");
continue;
}

hr1 = time1.substring(0,2);

最佳答案

伪代码不是特定语言。当您

  • 不懂本地语言
  • 有比关心语法更好的事情要做

例子可以是 - 如果你想告诉别人如何制作一个方法来检查有多少数组元素是奇数你可以写

 for every element in the array:
if is odd:
increase odd_counter
else
do nothing

print odd_counter

这不是任何语言,它只是“如何写得更少或更多”


只是为了让它更明显 - 请查看下面的 tcooc 的 评论 - Java/C++/etc 中的有效代码也可以是伪代码

关于Java编码转换为伪代码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33108809/

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