利用递归函数调用方式,将所输入的5个字符,以相反顺序打印出来。怎么用java实现
答案:1 悬赏:70
解决时间 2021-01-03 08:55
- 提问者网友:神仙爷爷
- 2021-01-03 01:52
利用递归函数调用方式,将所输入的5个字符,以相反顺序打印出来。怎么用java实现
最佳答案
- 二级知识专家网友:桑稚给你看
- 2021-01-03 02:51
public class Test {
public static void main(String[] args) {
char[] c = {'a','b','c','d','e'};
show(c, 0);
}
public static void show(char[] c, int index) {
if(index < 0 || index >= c.length) return;
System.out.println(c[c.length - index - 1]);
show(c, index++);
}
}
public static void main(String[] args) {
char[] c = {'a','b','c','d','e'};
show(c, 0);
}
public static void show(char[] c, int index) {
if(index < 0 || index >= c.length) return;
System.out.println(c[c.length - index - 1]);
show(c, index++);
}
}
我要举报
如以上问答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯