Advertisement
Guest User

Untitled

a guest
Oct 15th, 2018
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.89 KB | None | 0 0
  1. import java.util.Arrays;
  2. import java.util.Random;
  3.  
  4. class Matrice
  5. {
  6. static int[][] matrice;
  7. static int m,n;
  8.  
  9. public static void init_matrice()
  10. {
  11. Random rand=new Random();
  12. Matrice.m=rand.nextInt(10);
  13. Matrice.n=rand.nextInt(10);
  14. Matrice.matrice=new int[m][n];
  15. int i,j;
  16. for(i=0;i<Matrice.matrice.length;i++)
  17. {
  18. for(j=0;j<Matrice.matrice[i].length;j++)
  19. {
  20. Matrice.matrice[i][j]=rand.nextInt(99);
  21. }
  22. }
  23. }
  24. public static void print_matrice()
  25. {
  26. int i,j;
  27. for(i=0;i<Matrice.matrice.length;i++)
  28. {
  29. for(j=0;j<Matrice.matrice[i].length;j++)
  30. {
  31. System.out.print(Matrice.matrice[i][j]+" ");
  32. }
  33. System.out.println();
  34. }
  35. }
  36. public static void div_five()
  37. {
  38. int i,j;
  39. for(i=0;i<Matrice.matrice.length;i++)
  40. {
  41. for(j=0;j<Matrice.matrice[i].length;j++)
  42. {
  43. if(Matrice.matrice[i][j]%5==0)
  44. {
  45. System.out.printf("Numarul %d este divizibil cu 5: \n",Matrice.matrice[i][j]);
  46. System.out.printf("Si se afla pe pozitia:[%d][%d] \n",i,j);
  47. }
  48. }
  49. }
  50. }
  51. public static void col_sum_min()
  52. {
  53. int i,j,k=0,sum=0;
  54. int []ary=new int[Matrice.m];
  55. for(i=0;i<Matrice.matrice.length;i++)
  56. {
  57. sum=sum+Matrice.matrice[k][i];
  58. ary[i]=sum;
  59. k++;
  60. }
  61. Arrays.sort(ary);
  62. System.out.println("Suma cea mai mica este: "+ary[0]);
  63. }
  64. public static void pct_sa()
  65. {
  66. int i,j,k=0;
  67. for(i=0;i<Matrice.matrice.length;i++)
  68. {
  69. for(j=0;j<Matrice.matrice[i].length;j++)
  70. {
  71. if(Matrice.matrice[k][j]>Matrice.matrice[k][j++])
  72. {
  73. if(Matrice.matrice[i][k]<Matrice.matrice[i][k+1])
  74. {
  75. System.out.printf("Numarul %d este punct sa ! ",Matrice.matrice[i][j]);
  76. }
  77. }
  78. k++;
  79. }
  80. }
  81. }
  82. }
  83.  
  84. public class clasa
  85. {
  86. public static void main(String args[])
  87. {
  88. Matrice.init_matrice();
  89. Matrice.print_matrice();
  90. Matrice.div_five();
  91. Matrice.col_sum_min();
  92. Matrice.pct_sa();
  93. }
  94. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement