Answer:
done
Step-by-step explanation:
int a[][] = new int[4][4];
Random r = new Random();
for(int i=0;i<4;i++)
for(int j=0;j<4;j++)
{
a[i][j]=r.nextInt()%100;
}
int sorted1Darray[] = new int [16];
int k=0;
for(int i=0;i<4;i++)
for(int j=0;j<4;j++)
sorted1Darray[k++]=a[i][j];
//now sorting using bubble sort
for(int i=0;i<16;i++)
for(int j=0;j<16;j++)
if(sorted1Darray[i]<sorted1Darray[j])
{
int t= sorted1Darray[i];
sorted1Darray[i]=sorted1Darray[j];
sorted1Darray[j]=t;
}
System.out.println("Sorted array:");
for(int i=0;i<16;i++)
System.out.print(sorted1Darray[i]+" ");
System.out.println();