praktikum4 ülessanded
This commit is contained in:
@@ -3,28 +3,35 @@ package praktikum4;
|
||||
public class table2 {
|
||||
|
||||
public static void main(String[] args) {
|
||||
System.out.printf("Tabeli X suurus: ");
|
||||
System.out.printf("Tabeli 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
|
||||
int y_size = x_size; // table size in y direction
|
||||
|
||||
// Create the table
|
||||
System.out.printf("--");
|
||||
for (int x = 0; x <= x_size; x++) {
|
||||
System.out.printf("--");
|
||||
}
|
||||
System.out.printf("%n");
|
||||
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 ");
|
||||
if (x==y) {
|
||||
System.out.printf("x ");
|
||||
} else if (y+x == x_size) {
|
||||
System.out.printf("x ");
|
||||
} else {
|
||||
System.out.printf("0 ");
|
||||
}
|
||||
|
||||
}
|
||||
//we are at the end of the line, start a new one
|
||||
System.out.printf("%n");
|
||||
System.out.printf("|%n");
|
||||
}
|
||||
System.out.printf("--");
|
||||
for (int x = 0; x <= x_size; x++) {
|
||||
System.out.printf("--");
|
||||
}
|
||||
System.out.printf("-%n");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user