package C; public class Wugeren { static int age(int n) { int c; if( n==1 ) c=10; else c=age(n-1)+2; return c; } public static void main(String[] args) { // int a1=10; // int a2=a1+2; // int a3=a2+2; // int a4=a3+2; // int a5=a4+2; // System.out.println("第五个人的年龄为 "+a5+" 岁"); System.out.println("第五个人的年龄:"+Wugeren.age(5)); } }
转载于:https://www.cnblogs.com/wenwen123/p/5579848.html