Created
March 29, 2019 20:00
-
-
Save Isbena-4/7e3a628c55d6d9d26f428b9e268e132e to your computer and use it in GitHub Desktop.
Muli
This file contains 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
package Lista5; | |
import java.util.Scanner; | |
public class Zaad3 { | |
public static void main(String[] args) { | |
int k, b = 0; | |
System.out.println("Podaj n"); | |
Scanner reader = new Scanner(System.in); | |
Integer n = reader.nextInt(); | |
//System.out.println(n); | |
reader.close(); | |
int [][] tabliczka = new int[n][n]; | |
int row = 0; | |
tabliczka=timesTable(n,n); | |
for(row = 0; row <tabliczka.length; row++) | |
{ | |
for( int column = 0; column <tabliczka[row].length; column++) | |
{ | |
String s = ""; | |
s += Integer.toString(tabliczka[row][column]); | |
int p = s.length(); | |
//System.out.print(s); | |
//System.out.print(p); | |
int o = String.valueOf(n*column).length(); //last el | |
int r = p-o; | |
System.out.print(r); | |
/* | |
for(int z = 0; z <r; z++) | |
{ | |
System.out.print(" "); | |
} | |
//System.out.print(" "+tabliczka[row][column]); | |
*/ | |
//int l = (Math.pow(r,2)+" ").length() -1; | |
//if(column<9) | |
{ | |
//System.out.print(" "+ tabliczka[row][column]); | |
} | |
//System.out.print(s); | |
//System.out.printf("%"+o +"d", s); | |
/* | |
int p = s.length(); | |
StringBuilder k = new StringBuilder().append(" "); | |
System.out.print(s +k); | |
*/ | |
} | |
System.out.println(); | |
} | |
} | |
public static int[][] timesTable(int r, int c) | |
{ | |
int [][] yes = new int[r][c]; | |
for (int row =0; row < yes.length; row++) | |
{ | |
for(int column =0; column <yes[row].length; column++) | |
{ | |
yes[row][column] = (row+1)*(column+1); | |
} | |
} | |
return yes; | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment