第二次測試補做
阿新 • • 發佈:2018-03-26
markdown str ber rgs bus static code 調試 BE
1.P29
2.P45
3.遞歸循環
代碼
import java.util.Scanner; public class text2 { public static void main(String[] args) { long sum = 0; Scanner scanner = new Scanner(System.in); System.out.println("Please input n:"); int n = scanner.nextInt(); if (n < 0) { System.out.println("Please input a number "); } for (int i = 1; i <= n; i++) { sum += fact(i); } if(n>0) System.out.println("1!+...+"+n+"!="+sum); else System.out.println("0!="+1); } public static long fact(int t) { if (t == 0) return 1; else return t * fact(t - 1); } }
4.jdb
可能是因為電腦的問題,我在使用git bush對上述代碼進行調試總是失敗,我會在安裝好虛擬機之後補上本次內容。
第二次測試補做