java 指数函数递归 并且打印*星号

图片说明

如图

不能用循环

class Q1065412 {
    public static void printPowerOfTwoStars(int n)
    {
        if (n == 0)
            System.out.print("*");
        else if (n == 1)
            System.out.print("**");
        else
        {
            printPowerOfTwoStars(n - 1);
            printPowerOfTwoStars(n - 1);
        }
    }
    public static void main(String[] args) {
        printPowerOfTwoStars(4);
    }
}

如果问题得到解决,请点下采纳