Click here to Skip to main content
15,569,840 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
import java.util.Scanner;

public class matrix {
    public static void main(String[] args) {
        int a, b;
        try (Scanner s = new Scanner(System.in)) {
            System.out.println("Enter total rows: ");
            int row = s.nextInt();
            System.out.println("Enter total columns: ");
            int column = s.nextInt();
            int array[][] = new int[row][column];
            {
                System.out.println("Enter Elements: ");
                for (a = 0; a < row; a++) {
                    for (b = 0; b < column; b++) {

                        array[a][b] = s.nextInt();
                        System.out.print("");

                    }
                }
                System.out.print("");

                System.out.println(" Matrix before Transpose is ");
                for (a = 0; a < row; a++) {
                    for (b = 0; b < column; b++) {
                        System.out.print(" " + array[a][b] + " ");
                    }
                    System.out.println();
                }
                System.out.println("");
                System.out.println("The above matrix after Transpose is ");
                for (a = 0; a < column; a++) {
                    for (b = 0; b < row; b++) {
                        System.out.print(" " + array[b][a] + " ");
                    }
                    System.out.println("");

                }
                System.out.println("");

                int max = Integer.MIN_VALUE;
                for (a = 0; a < row; a++) {
                    for (b = 0; b < column; b++) {
                        if (max < array[a][b]) {
                            max = array[a][b];
                        }
                    }
                }

                System.out.println("Maximum number in the matrix is " + max);
            }
        }
        System.out.println();
        // System.out.println("Matrix in asscending order"+);

    }
}


What I have tried:

I want ascending order in this code only please help
Posted
Updated 20-Mar-22 5:58am
Comments
Richard MacCutchan 20-Mar-22 10:43am    
So what is the problem?
B A Z Gaming 20-Mar-22 10:45am    
I don't know how to sort array in ascending order and i want solution in this code only i don't want to change code

Question of this project to transpose the array and get the highest no. In array and ascending order of array i got stucked in ascending
Richard MacCutchan 20-Mar-22 10:53am    
You are assuming that we understand what this code is supposed to do and what it is not doing, or not doing correctly. We have never seen this code before and have no idea what its purpose is so you need to explain in proper detail, what it does or does not do correctly.

And if you expect someone to write your college assignment for you then I am afraid you are in the wrong forum.
B A Z Gaming 20-Mar-22 10:57am    
Thank you , it's ok if you don't understand the code now you can stop wasting my time
Richard MacCutchan 20-Mar-22 10:58am    
Thank you for giving me permission, I certainly will.

1 solution

Quote:
i want solution in this code only i don't want to change code

You do realize that that isn't possible, unless that code does exactly what you want it to already - which it clearly doesn't or you wouldn't be posting here.

We can't fix problems without changing things, in software or in anything!

As regards writing the sort code for you ... While we are more than willing to help those that are stuck, that doesn't mean that we are here to do it all for you! We can't do all the work, you are either getting paid for this, or it's part of your grades and it wouldn't be at all fair for us to do it all for you.

So we need you to do the work, and we will help you when you get stuck. That doesn't mean we will give you a step by step solution you can hand in!
Start by explaining where you are at the moment, and what the next step in the process is. Then tell us what you have tried to get that next step working, and what happened when you did.

If you are having problems getting started at all, then this may help: How to Write Code to Solve a Problem, A Beginner's Guide[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900