Skip to content

Instantly share code, notes, and snippets.

@HabaCo
Created June 10, 2014 13:02
Show Gist options
  • Save HabaCo/f8e18a6a44e516d0bac3 to your computer and use it in GitHub Desktop.
Save HabaCo/f8e18a6a44e516d0bac3 to your computer and use it in GitHub Desktop.
讀檔&數列直角三角形
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