Advertisement
Guest User

Untitled

a guest
Sep 24th, 2017
44
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.54 KB | None | 0 0
  1. public class Ficha2Ex5 {
  2.  
  3. /**
  4. * @param args the command line arguments
  5. */
  6. public static void main(String[] args) {
  7. int [][]array = new int [5][10];
  8. int [][]array2 = new int [5][10];
  9. int [][]array3 = new int [5][10];
  10.  
  11. preenche_array(array);
  12. escreve_array(array);
  13.  
  14. preenche_colcol(array2);
  15. escreve_array(array2);
  16.  
  17. preenche_linlin(array3);
  18. escreve_array(array3);
  19. // TODO code application logic here
  20. }
  21.  
  22.  
  23. static void preenche_array(int [][]array){
  24. int i,j,x;
  25. for(j = 0; j < 10; j++ ){
  26. for(i = 0; i < 5; i++){
  27. x = (int) (Math.random() * 100);
  28. array[i][j] = x;
  29. }
  30. }
  31. }
  32.  
  33. static void escreve_array(int [][]array){
  34. int i, j;
  35. for(j = 0; j < 10; j++){
  36. for(i = 0; i < 5; i++){
  37. System.out.println(array[i][j]+" ");
  38. }
  39. System.out.println("\n");
  40. }
  41. }
  42.  
  43. static void preenche_linlin(int [][]array){
  44. int i,j,aux = 0;
  45. for(j = 0; j < 10; j++){
  46. for(i = 0; i < 5; i++){
  47. array[i][j] = aux;
  48. aux++;
  49. }
  50. }
  51. }
  52.  
  53. static void preenche_colcol(int [][]array){
  54. int i,j, aux = 0;
  55. for(i = 0; i < 5; i++){
  56. for(j= 0; j < 10; j++){
  57. array[i][j] = aux;
  58. aux++;
  59. }
  60. }
  61. }
  62. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement