Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Arrays;
- import java.util.Random;
- class Matrice
- {
- static int[][] matrice;
- static int m,n;
- public static void init_matrice()
- {
- Random rand=new Random();
- Matrice.m=rand.nextInt(10);
- Matrice.n=rand.nextInt(10);
- Matrice.matrice=new int[m][n];
- int i,j;
- for(i=0;i<Matrice.matrice.length;i++)
- {
- for(j=0;j<Matrice.matrice[i].length;j++)
- {
- Matrice.matrice[i][j]=rand.nextInt(99);
- }
- }
- }
- public static void print_matrice()
- {
- int i,j;
- for(i=0;i<Matrice.matrice.length;i++)
- {
- for(j=0;j<Matrice.matrice[i].length;j++)
- {
- System.out.print(Matrice.matrice[i][j]+" ");
- }
- System.out.println();
- }
- }
- public static void div_five()
- {
- int i,j;
- for(i=0;i<Matrice.matrice.length;i++)
- {
- for(j=0;j<Matrice.matrice[i].length;j++)
- {
- if(Matrice.matrice[i][j]%5==0)
- {
- System.out.printf("Numarul %d este divizibil cu 5: \n",Matrice.matrice[i][j]);
- System.out.printf("Si se afla pe pozitia:[%d][%d] \n",i,j);
- }
- }
- }
- }
- public static void col_sum_min()
- {
- int i,j,k=0,sum=0;
- int []ary=new int[Matrice.m];
- for(i=0;i<Matrice.matrice.length;i++)
- {
- sum=sum+Matrice.matrice[k][i];
- ary[i]=sum;
- k++;
- }
- Arrays.sort(ary);
- System.out.println("Suma cea mai mica este: "+ary[0]);
- }
- public static void pct_sa()
- {
- int i,j,k=0;
- for(i=0;i<Matrice.matrice.length;i++)
- {
- for(j=0;j<Matrice.matrice[i].length;j++)
- {
- if(Matrice.matrice[k][j]>Matrice.matrice[k][j++])
- {
- if(Matrice.matrice[i][k]<Matrice.matrice[i][k+1])
- {
- System.out.printf("Numarul %d este punct sa ! ",Matrice.matrice[i][j]);
- }
- }
- k++;
- }
- }
- }
- }
- public class clasa
- {
- public static void main(String args[])
- {
- Matrice.init_matrice();
- Matrice.print_matrice();
- Matrice.div_five();
- Matrice.col_sum_min();
- Matrice.pct_sa();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement