Created
June 10, 2014 13:02
-
-
Save HabaCo/f8e18a6a44e516d0bac3 to your computer and use it in GitHub Desktop.
讀檔&數列直角三角形
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import java.io.File; | |
| import java.io.IOException; | |
| import java.util.Scanner; | |
| // 數列直角三角形 | |
| public class Q940302 { | |
| public static void main(String[] args) throws IOException { | |
| String fileName = "940302.SM"; | |
| File f = new File(fileName); | |
| Scanner sc = new Scanner(f); | |
| while (sc.hasNext()){ | |
| int n = sc.nextInt(); | |
| for (int i=1; i<=n; i++){ | |
| for (int j=1; j<=i; j++) // j 隨著 i 遞增而遞增 | |
| System.out.print(j); | |
| System.out.println(); | |
| } | |
| } | |
| sc.close(); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment