Advertisement
Guest User

Untitled

a guest
Apr 27th, 2015
189
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.66 KB | None | 0 0
  1. /*
  2. * To change this license header, choose License Headers in Project Properties.
  3. * To change this template file, choose Tools | Templates
  4. * and open the template in the editor.
  5. */
  6. package quientoejercicio;
  7. import javax.swing.*;
  8. /**
  9. *
  10. * @author deiby
  11. */
  12. public class QuientoEjercicio {
  13.  
  14. static int Vect[][];
  15. static String Mensaje = "";
  16. /**
  17. * @param args the command line arguments
  18. */
  19. public static void main(String[] args) {
  20. // TODO code application logic here
  21.  
  22. int n = Integer.parseInt(JOptionPane.showInputDialog(" Introduzca el numero de filas "));
  23. int Vect[][] = new int[n][3];
  24.  
  25. LLenarVector(Vect);
  26. MostrarVector(Vect);
  27.  
  28. }
  29.  
  30. public static void LLenarVector(int Vect[][])
  31. {
  32. for(int i = 0; i < Vect.length; i++)
  33. {
  34. for(int j = 0; j < Vect[i].length-1; j++)
  35. {
  36. Vect[i][j] = Integer.parseInt(JOptionPane.showInputDialog(" Introduzca los numeros " + (i) + (j)));
  37.  
  38. }
  39. }
  40.  
  41. }
  42.  
  43. public static void MostrarVector(int Vect[][])
  44. {
  45. for(int i = 0; i < Vect.length; i++)
  46. {
  47. for(int j = 0; j < Vect[i].length; j++)
  48. {
  49. int Suma = (Vect[i][j] + Vect[i][j]);
  50. if(Vect[i][2] == 0)
  51. {
  52. Vect[i][2] = Suma;
  53. Mensaje = Mensaje + Vect[i][j] + " + " + Vect[i][j] + " = " + Suma + "\n";
  54. }
  55.  
  56. }
  57. }
  58.  
  59. JOptionPane.showMessageDialog(null,Mensaje);
  60. }
  61. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement