解题思路:
注意事项:
参考代码:
import java.util.Scanner; public class Main{ public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); while (n!=0){ System.out.println(dg(n)); n = sc.nextInt(); } } public static int dg(int n){ if (n<=4){ return n; } return dg(n-1)+dg(n-3); } }
0.0分
1 人评分
时间转换 (Java代码)浏览:574 |
C语言程序设计教程(第三版)课后习题4.9 (C语言代码)浏览:377 |
C语言程序设计教程(第三版)课后习题7.5 (C语言代码)浏览:856 |
WU-输入输出格式练习 (C++代码)浏览:1082 |
用筛法求之N内的素数。 (C语言代码)浏览:806 |
母牛的故事 (C语言代码)浏览:1428 |
2006年春浙江省计算机等级考试二级C 编程题(2) (C语言代码)浏览:344 |
C语言训练-自守数问题 (C语言代码)浏览:748 |
简单的a+b (C语言代码)浏览:504 |
C二级辅导-公约公倍 (C语言代码)浏览:1311 |