something
This commit is contained in:
30
src/praktikum4/table2.java
Normal file
30
src/praktikum4/table2.java
Normal file
@@ -0,0 +1,30 @@
|
||||
package praktikum4;
|
||||
|
||||
public class table2 {
|
||||
|
||||
public static void main(String[] args) {
|
||||
System.out.printf("Tabeli X suurus: ");
|
||||
int x_size = lib.TextIO.getlnInt(); // table size in x direction
|
||||
System.out.printf("Tabeli Y suurus: ");
|
||||
int y_size = lib.TextIO.getlnInt(); // table size in y direction
|
||||
|
||||
// Create the table
|
||||
for (int x = 0; x <= x_size; x++) {
|
||||
System.out.printf("--");
|
||||
}
|
||||
System.out.printf("%n");
|
||||
for (int x = 0; x <= x_size; x++) {
|
||||
System.out.printf("| ");
|
||||
for (int y = 0; y <= y_size; y++) {
|
||||
if (x == y) {
|
||||
System.out.printf("1 ");
|
||||
} else {
|
||||
System.out.printf("0 ");
|
||||
}
|
||||
|
||||
}
|
||||
//we are at the end of the line, start a new one
|
||||
System.out.printf("%n");
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user