递归章节后面的程序设计项目题.老外的题目就是怪
想了半天做不出..谁能帮忙做下.编写一个能产生如下所示输出结果的方法.所示的输出结果
是通过调用数值1产生的.在这个例子中,递归到达4层深度时停止,
但要求所编写的方法应该能继续到任意指定层(注意空格). This was written by call number 2.
This was written by call number 3.
This was written by call number 4.
This ALSO written by call number 4.
This ALSO written by call number 3.
This ALSO written by call number 2.
This ALSO written by call number 1.
想了半天做不出..谁能帮忙做下.编写一个能产生如下所示输出结果的方法.所示的输出结果
是通过调用数值1产生的.在这个例子中,递归到达4层深度时停止,
但要求所编写的方法应该能继续到任意指定层(注意空格). This was written by call number 2.
This was written by call number 3.
This was written by call number 4.
This ALSO written by call number 4.
This ALSO written by call number 3.
This ALSO written by call number 2.
This ALSO written by call number 1.
解决方案 »
- java 程序设计 求案例
- JAVA如何取得上一个月的同一天
- 使用反射机制怎么判断一个类是否已经被实例化?
- 哪位高手能帮小弟写一个正则式啊?谢谢啊
- 还是那个打包成可执行jar问题
- 我得到了当前使用的字体对象,但是他用的是粗体的(bold),如何把他改为不是粗体的(normal)
- 如何解决JCreator Pro对中文的支持?高分相赠
- 我是初学者,有几个问题,想请教各位高手,望不吝赐教
- TreeView的 滚动条怎么用?
- String a = "提问"; 这个过程中,"提问"存放的位置到底是哪里?
- Java基础 List 的简单操作,寻求高效率的解答。。。。在线-----昨天发过此帖,问题描述错误,所以今天重发
- 如何获得一个不确定的BEAN中属性的个数
public static void itePrint(int i,int stopLevel)
{
if(i==stopLevel)
{
System.out.println("also "+ i);
}
else
{
System.out.println("was "+ i);
itePrint(i+1,stopLevel);
System.out.println("also "+ i);
}
} public static void main(String[] args) throws UnsupportedEncodingException
{
itePrint(1,4);
}
public static void main(String[] args) {
print(2, 4, 1);
} void print(int min, int max, int index) {
if (index >= min) {
if (index > min) {
System.out.print(" ");
}
System.out.println("This was written by call number " + index + ".");
}
if (index < max) {
print(base, length, index + 1);
}
if (index > min) {
System.out.println(" ");
}
System.out.println("This ALSO written by call number " + index + ".");
}
}