📜  在 Java 代码示例中使用递归的模式

📅  最后修改于: 2022-03-11 14:52:26.165000             🧑  作者: Mango

代码示例1
1234567891011121314151617181920212223242526
import java.lang.String;import java.util.Scanner;public class Main{    // function to print the required pattern    public static String func(int n) {        //write your code he        if(n<=0)        {            return "";        }            String res=func(n-1);            res=res+"*";            System.out.println(res);            return res;        }    public static void main(String[] args) {        Scanner in = new Scanner(System.in);        int n = in.nextInt();        func(n);    }}