Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Created by satellite on 21.02.2017.
- */
- public class latinSquare {
- public static void main(String[] args) {
- int dim = 4;
- String type = "greek";
- if (args.length < 1 || args.length > 2)
- System.out.println("Prea putini parametri.");
- else if (args.length == 1) {
- dim = Integer.parseInt(args[0]);
- type = "latin";
- } else if (args.length == 2) {
- dim = Integer.parseInt(args[0]);
- type = args[1];
- }
- System.out.println("Dimensiune matrice: " + dim);
- System.out.println("Limbaj: " + type);
- char[][] matrix = new char[50][50];
- if(type.compareTo("latin") == 0)
- for(int i = 0; i<dim; i++)
- matrix[0][i] = ((char)('A' + i));
- else if(type.compareTo("greek") == 0)
- for(int i = 0; i<dim; i++)
- matrix[0][i] = (char)(('\u03B1' + i));
- for(int i = 1; i<dim; i++) {
- System.arraycopy(matrix[i - 1], 1, matrix[i], 0, dim);
- System.arraycopy(matrix[i - 1], 0, matrix[i], dim - 1, 1);
- }
- for (int i = 0; i < dim; i++) {
- for (int j = 0; j < dim; j++)
- System.out.print( matrix[i][j] + " ");
- System.out.println();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement