# quiz asked by my lecturer for array reverse....

consider a 2 dimensional array size m by n.Derive a function that can be used to reverse the elements of the array such that the last element of the array becomes the first..and the first element becomes the last.Code the algorithm and give the output.

November 19, 2010 at 12:05 PM

Hello Friend,

Try the following code:

```import java.util.*;

public class TDArray {
public static void reverse(int[][] arr){

int rows = arr.length;
int cols = arr[0].length;
int[][] reverse = new int[rows][cols];
for(int i = rows-1; i >= 0; i--) {
for(int j = cols-1; j >= 0; j--) {
reverse[rows-1-i][cols-1-j] = arr[i][j];
}
}
for(int i = 0; i < rows; i++) {
for(int j = 0; j < cols; j++) {
System.out.print(reverse[i][j]);
if(j < cols-1)
System.out.print(", ");
}
System.out.println();
}
}

public static void main(String[] args) throws Exception {
int rows, cols;
int[][] arr={{10,20,30,40,},{50,60,70,80}};
reverse(arr);

}
}
```

Thanks

quiz asked by my lecturer for array reverse....
quiz asked by my lecturer for array reverse....  consider a 2 dimensional array size m by n.Derive a function that can be used to reverse the elements of the array such that the last element of the array becomes the first
quiz asked by my lecturer for array reverse....
quiz asked by my lecturer for array reverse....  consider a 2 dimensional array size m by n.Derive a function that can be used to reverse the elements of the array such that the last element of the array becomes the first
Reverse integer array program
Reverse integer array program  Been tasked with the following question: Write a method that accepts an integer array and returns a new array with all the elements in reverse order. For example, if the input array is [2, 4, 6, 8
PHP Array Sort in Reverse Order
PHP Array Sort in Reverse Order  Hi, I have just started learning... the PHP Array Sort in Reverse Order. Please suggest any online reference or example... the Reference example of PHP Array Sort in Reverse Order. Thanks
Java Reverse integer array
Java Reverse integer array In this tutorial, you will learn how to reverse integer array. Here, we have created a method to reverse an array which has been passed as a parameter and returns a new array with all the elements in reverse
JavaScript array reverse example
JavaScript array reverse example       JavaScript Array class have one method reverse() which will reverse the order of element into the array. This has a simple syntax
ARRAY REVERSE - Java Interview Questions
ARRAY REVERSE  Hi,I Have Array Like This int arr[]={1,3,4,6,7,9,6,4} I Want Print Reverse Order Like This 4,6,9,7,6,4,3,1 Using loops I Want Source Code Plz Help me?  Hi Friend, Try the following code: class
PHP Array Reverse
Php array is reversed by the function array_reverse(). array_reverse.... PHP Array Reverse Example <?php     \$arr=array("car... are <br>";     \$arr1=array_reverse(\$arr);
PHP Array Reverse Sorting
PHP Array Sort in Reverse Order In PHP there are three functions are available...() is one of them, it sorts an array in reverse order, rsort() is just opposite sort... that this function will sort an array in reverse order and maintain index association like
quiz
question has a complexity (difficulty) level. Use the Question class to define a Quiz class. A quiz can be composed of up to 10 questions. Define the add method of the Quiz class to add a question to a quiz. Define the giveQuiz method
Reverse
Reverse  How to reverse two digits in javaprogramming
Reverse
Reverse  How to reverse two digits in javaprogramming
reverse
reverse  program to read a string and print the reverse string   Hi Friend, Try the following code:ADS_TO_REPLACE_1 import java.util.*; public class ReverseString{ public static void main(String[]args
data science lecturer jobs
data science lecturer jobs  Hi, I am beginner in Data Science... lecturer jobs Try to provide me good examples or tutorials links so that I can learn the topic "data science lecturer jobs". Also tell me which
ModuleNotFoundError: No module named 'quiz'
ModuleNotFoundError: No module named 'quiz'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'quiz' How to remove the ModuleNotFoundError: No module named 'quiz' error
online quiz
) level. Use the Question class to define a Quiz class. A quiz can be composed of up to 10 questions. Define the add method of the Quiz class to add a question to a quiz. Define the giveQuiz method of the Quiz class to present each question
online quiz
) level. Use the Question class to define a Quiz class. A quiz can be composed of up to 10 questions. Define the add method of the Quiz class to add a question to a quiz. Define the giveQuiz method of the Quiz class to present each question
online quiz
) level. Use the Question class to define a Quiz class. A quiz can be composed of up to 10 questions. Define the add method of the Quiz class to add a question to a quiz. Define the giveQuiz method of the Quiz class to present each question
online quiz
) level. Use the Question class to define a Quiz class. A quiz can be composed of up to 10 questions. Define the add method of the Quiz class to add a question to a quiz. Define the giveQuiz method of the Quiz class to present each question
online quiz
) level. Use the Question class to define a Quiz class. A quiz can be composed of up to 10 questions. Define the add method of the Quiz class to add a question to a quiz. Define the giveQuiz method of the Quiz class to present each question
plz try to clear my doubt for shuffling multi-dimensional array
plz try to clear my doubt for shuffling multi-dimensional array  hi... want to shuffle the ful entire multi-simensional array means wat v want to do... final int size = 5; private int[][] array = new int[size][size]; private
online quiz
) level. Use the Question class to define a Quiz class. A quiz can be composed of up to 10 questions. Define the add method of the Quiz class to add a question to a quiz. Define the giveQuiz method of the Quiz class to present each question
reverse arrays in java
reverse arrays in java  how do i make a code that can be used to reverse the elements of an array in two dimension such that the last element of an array becomes the first element of the array and the first element of an array
reverse two dimensional arrays in java
reverse two dimensional arrays in java  reverse array elements in two dimensional array such that the last element becomes the first
ModuleNotFoundError: No module named 'kotti_quiz'
ModuleNotFoundError: No module named 'kotti_quiz'  Hi, My Python... 'kotti_quiz' How to remove the ModuleNotFoundError: No module named 'kotti_quiz' error? Thanks   Hi, In your python environment you
ModuleNotFoundError: No module named 'py-quiz'
ModuleNotFoundError: No module named 'py-quiz'  Hi, My Python...-quiz' How to remove the ModuleNotFoundError: No module named 'py-quiz... to install padas library. You can install py-quiz python with following command
ModuleNotFoundError: No module named 'simple-quiz'
ModuleNotFoundError: No module named 'simple-quiz'  Hi, My Python... 'simple-quiz' How to remove the ModuleNotFoundError: No module named 'simple-quiz' error? Thanks   Hi, In your python environment
ModuleNotFoundError: No module named 'django-quiz'
ModuleNotFoundError: No module named 'django-quiz'  Hi, My Python... 'django-quiz' How to remove the ModuleNotFoundError: No module named 'django-quiz' error? Thanks   Hi, In your python environment
array
array  write and test a function named mirror that is passed an array of n floats and returns a newly created array that contains those n floats values in reverse order . for example, the call of mirror function would transform
array
array  write and test a function named mirror that is passed an array of n floats and returns a newly created array that contains those n floats values in reverse order . for example, the call of mirror function would transform
array
array  write and test a function named mirror that is passed an array of n floats and returns a newly created array that contains those n floats values in reverse order . for example, the call of mirror function would transform
reverse the charstring
reverse the charstring  how to reverse any character of the string
ModuleNotFoundError: No module named 'comp-sci-quiz'
ModuleNotFoundError: No module named 'comp-sci-quiz'  Hi, My... 'comp-sci-quiz' How to remove the ModuleNotFoundError: No module named 'comp-sci-quiz' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'comp-sci-quiz'
ModuleNotFoundError: No module named 'comp-sci-quiz'  Hi, My... 'comp-sci-quiz' How to remove the ModuleNotFoundError: No module named 'comp-sci-quiz' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'django-simple-quiz'
ModuleNotFoundError: No module named 'django-simple-quiz'  Hi, My... named 'django-simple-quiz' How to remove the ModuleNotFoundError: No module named 'django-simple-quiz' error? Thanks   Hi, In your
ModuleNotFoundError: No module named 'comp-sci-quiz'
ModuleNotFoundError: No module named 'comp-sci-quiz'  Hi, My... 'comp-sci-quiz' How to remove the ModuleNotFoundError: No module named 'comp-sci-quiz' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'django-quiz-app'
ModuleNotFoundError: No module named 'django-quiz-app'  Hi, My... named 'django-quiz-app' How to remove the ModuleNotFoundError: No module named 'django-quiz-app' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'django-simple-quiz'
ModuleNotFoundError: No module named 'django-simple-quiz'  Hi, My... named 'django-simple-quiz' How to remove the ModuleNotFoundError: No module named 'django-simple-quiz' error? Thanks   Hi, In your
array
array  wap to calculate reverse of 10 elements in an array?  ...(); } System.out.print("Array is: "); for(int i=0;i<arr.length;i...(); System.out.print("After reversing, Array is: "); for(int i=arr.length-1;i>=0
ModuleNotFoundError: No module named 'reverse'
ModuleNotFoundError: No module named 'reverse'  Hi, My Python... 'reverse' How to remove the ModuleNotFoundError: No module named 'reverse... to install padas library. You can install reverse python with following command
reverse arrays in java
reverse arrays in java  how do i write a program in array of size n*m where both n and m are greater than 20 such that the 1st element of an array becomes the last and vice verse
Online quiz mini project
Online quiz mini project  Sir i need a online quiz program coding using java servlet, jdbc odbc connection with ms. access. If possible send that source code to me. Thank you
Online quiz mini project
Online quiz mini project  Hi. I follow one of the code for "Online quiz mini project". I would like to know how to count the number of wrong answers in jsp
reverse string
reverse string  how to reverse a string without changing its place...=input.nextLine(); String reverse = new StringBuffer(str).reverse().toString(); System.out.println("Reverse: " + reverse); } } Thanks
String reverse program
String reverse program  write a java program for reverse string? if the string is "Hi welcome to hyderabad" the reverse string is "hyderabad... for help. You can split the String into String array using split method of String
How to Create Quiz Application using iPhone
How to Create Quiz Application using iPhone  Hi, I am learning iphone application Programming Language. my question is that how to create a quiz...; Hi, It is very easy to create a quiz application for iphone. The below link
reverse alphabet
reverse alphabet  e d c b a d c b a c b a b a a code for this pattern in c language
in_array
in_array  in_array in php
identification quiz - Java Beginners
identification quiz  what is the html java code for a identification quiz? plz help me..  Hi Friend, Please clarify your question. Thanks
is _array()
is _array()  is_array() in php   Hi Friend, This function is of Boolean type.It checks whether a variable is an array or not. Here is an example: <?php \$yes = array('Hello', 'World'); echo is_array(\$yes) ? 'Array