Guest User

Untitled

a guest
Apr 23rd, 2018
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.24 KB | None | 0 0
  1. import javax.swing.*;
  2. public class Boomer
  3. {
  4.     public static void main (String [] args)
  5.     {
  6.         String righe = JOptionPane.showInputDialog("inserisci le righe della matrice");
  7.         String colonne = JOptionPane.showInputDialog("inserisci le colonne della matrice");
  8.         int r = Integer.parseInt (righe);
  9.         int c = Integer.parseInt (colonne);
  10.         float [] [] matrice = new float [r][c];
  11.         int i,j;
  12.        
  13.         //Caricamento Matrice
  14.             for (i=0;i<r;i++)
  15.                 {
  16.                     for (j=0;j<c;j++)
  17.                         {
  18.                             String primonum = JOptionPane.showInputDialog("inserisci il valore nella posizione "+i+" e "+j);
  19.                             matrice[i] [j] = Integer.parseInt (primonum);
  20.                         }
  21.    
  22.                 }
  23.        
  24.         //Caricamento double       
  25.         String d = JOptionPane.showInputDialog("inserisci il valore del double");          
  26.         double x = Double.parseDouble (d);
  27.  
  28.         //Confronto basi
  29.         double k;
  30.         int q=0;
  31.             for (i=0;i<r-1;i++)
  32.                 {
  33.                     for (j=0;j<c;j++)
  34.                         {
  35.                             k = matrice [i][j] + matrice [i][j+1] + matrice [i+1][j] + matrice [i+1][j+1];
  36.                             if (k>x/5)
  37.                             {
  38.                                 JOptionPane.showMessageDialog(null, "esiste una base x forte");
  39.                                 q++;
  40.                             }
  41.                            
  42.                         }
  43.                         break;
  44.    
  45.                 }
  46.         if (q==0)
  47.             JOptionPane.showMessageDialog(null, "non esiste una base x forte");
  48.     }
  49. }
Add Comment
Please, Sign In to add comment