Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import fond.io.*;
- public class ProvaMatriceDiStringhe {
- public static void main(String[] args) {
- InputWindow in = new InputWindow();
- OutputWindow out = new OutputWindow();
- int dim = in.readInt("Inserisci la dimensione della matrice:");
- String[][] m = new String[dim][dim];
- for(int i=0; i<dim; i++) {
- for(int j=0; j<dim; j++) {
- m[i][j] = in.readString("Inserisci la stringa di posizione " + i + ";" + j + " :");
- }
- }
- MatriceDiStringhe mds = new MatriceDiStringhe(m);
- out.writeln("Matrice Inserita:");
- out.writeln(m.toString());
- boolean continua = true;
- while (continua) {
- int i = in.readInt("Inserisci un indice di riga (0-" + (dim-1) + ") o -1 per uscire: ");
- if (i == -1) {
- continua = false;
- } else if (i < 0 || i >= dim) {
- out.writeln("Indice non valido!");
- } else {
- out.writeln("Minimo della riga " + i + ": "+mds.primaInRiga(i));
- }
- }
- MatriceDiStringhe sottomatrice = new MatriceDiStringhe(new String[dim/2][dim/2]);
- for (int i=0; i<dim; i+=2) {
- for (int j=0; j<dim; j+=2) {
- sottomatrice[i/2][j/2] = mds[i][j];
- }
- }
- out.writeln("Sottomatrice degli elementi con indici dispari:");
- out.writeln(sottomatrice);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement