sujana-kamasany / javacodes

A repository that will guide in making your first contribution.
29 stars 111 forks source link

Transpose of a Matrix #29

Open sujana-kamasany opened 2 years ago

sujana-kamasany commented 2 years ago

Java Program to Find Transpose of a Matrix

DHARUNKUMAR7 commented 2 years ago

My sol: public static void main(String[] args) throws Exception { Scanner in = new Scanner(System.in); int n = in.nextInt(); int m = in.nextInt(); int[][] arr = new int[n][m]; // Initializing a 2d array for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { arr[i][j] = in.nextInt(); } } //Main operation. for(int i = 0 ; i < n; i++){ for(int j = i ; j < m ; j++){ if(i != j){ int temp = arr[i][j]; arr[i][j] = arr[j][i]; arr[j][i] = temp; } } } System.out.println(Arrays.deepToString(arr)); }

sujana-kamasany commented 2 years ago

@DHARUNKUMAR7 Thank you for your solution ! Please go ahead and make a pull request

matteopagano commented 2 years ago

Look at my repo Matrix, is an API in java language for work with matrixes.

sujana-kamasany commented 2 years ago

Look at my repo Matrix, is an API in java language for work with matrixes.

@matteopagano sure ! Thanks for sharing this

kashish-51 commented 11 months ago

Hey, I want to work on this please assign me

sujana-kamasany commented 11 months ago

Hey, I want to work on this please assign me

Sure ! Please submit your solution