Page 1 :
Monday, August 16, 2021, 8:20 PM, , import java.util.*;, , COMBINED ISC 135 Page 1
Page 2 :
class mat1, {, public static void main(), {, int i,j,s=0;, Scanner sc=new Scanner(System.in);, int a[][]=new int[3][4];, System.out.println("Enter matrix elements");, for(i=0;i<3;i++), {, for(j=0;j<4;j++), {, System.out.print("a["+i+"]["+j+"]=");, a[i][j]=sc.nextInt();, }, }, System.out.println("Matrix elements are");, for(i=0;i<3;i++), {, for(j=0;j<4;j++), System.out.print(a[i][j]+"\t");, System.out.println();, }, , }, }, , COMBINED ISC 135 Page 2
Page 5 :
import java.util.*;, class arrangeboundry, {, static int a[][],r,c;, void accept(), {, int i,j;, Scanner sc=new Scanner(System.in);, System.out.println("Enter aaray elements");, for(i=0;i<r;i++), {, for(j=0;j<c;j++), a[i][j]=sc.nextInt();, , }, }, void display(int x[][],int r,int c), {, int i,j;, , System.out.println("Matrix elements are");, for(i=0;i<r;i++), {, for(j=0;j<c;j++), System.out.print(x[i][j]+"\t");, System.out.println();, }, }, void arrange(int x[][],int m,int n), {, int i,j,index,l,t1,r1,r2,c1,c2,k;, int t[]=new int[2*(m+n)-4];, , COMBINED ISC 135 Page 5
Page 6 :
index=0;, for(i=0;i<r;i++), {, for(j=0;j<c;j++), if(i==0||j==0||i==m-1||j==n-1), t[index++]=x[i][j];, }, //sorting, l=t.length;, for(i=0;i<l;i++), {, for(j=0;j<l-1-i;j++), {, if(t[j]>t[j+1]), {, t1=t[j];, t[j]=t[j+1];, t[j+1]=t1;, }, }, }, //refiil in 2d, r1=0;r2=m-1;c1=0;c2=n-1;k=0;, for(i=c1;i<=c2;i++), x[r1][i]=t[k++];, , for(i=r1+1;i<=r2;i++), x[i][c2]=t[k++];, for(i=c2-1;i>=c1;i--), x[r2][i]=t[k++];, for(i=r2-1;i>=r1+1;i--), x[i][c1]=t[k++];, }, public static void main(), {, Scanner sc=new Scanner(System.in);, arrangeboundry obj=new arrangeboundry();, System.out.println("Enter row and column");, r=sc.nextInt();, c=sc.nextInt();, a=new int[r][c];, obj.accept();, System.out.println("Original array is");, obj.display(a,r,c);, obj.arrange(a,r,c);, System.out.println("Sorted array is");, obj.display(a,r,c);, }, }, , COMBINED ISC 135 Page 6