Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import javax.swing.*;
- public class Boomer
- {
- public static void main (String [] args)
- {
- String righe = JOptionPane.showInputDialog("inserisci le righe della matrice");
- String colonne = JOptionPane.showInputDialog("inserisci le colonne della matrice");
- int r = Integer.parseInt (righe);
- int c = Integer.parseInt (colonne);
- float [] [] matrice = new float [r][c];
- int i,j;
- //Caricamento Matrice
- for (i=0;i<r;i++)
- {
- for (j=0;j<c;j++)
- {
- String primonum = JOptionPane.showInputDialog("inserisci il valore nella posizione "+i+" e "+j);
- matrice[i] [j] = Integer.parseInt (primonum);
- }
- }
- //Caricamento double
- String d = JOptionPane.showInputDialog("inserisci il valore del double");
- double x = Double.parseDouble (d);
- //Confronto basi
- double k;
- int q=0;
- for (i=0;i<r-1;i++)
- {
- for (j=0;j<c;j++)
- {
- k = matrice [i][j] + matrice [i][j+1] + matrice [i+1][j] + matrice [i+1][j+1];
- if (k>x/5)
- {
- JOptionPane.showMessageDialog(null, "esiste una base x forte");
- q++;
- }
- }
- break;
- }
- if (q==0)
- JOptionPane.showMessageDialog(null, "non esiste una base x forte");
- }
- }
Add Comment
Please, Sign In to add comment