1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Olenka [21]
3 years ago
12

(Shuffle rows) Write a method that shuffles the rows in a two-dimensional int array using the following header: public static vo

id shuffle(int[][] m)
Computers and Technology
1 answer:
Lostsunrise [7]3 years ago
7 0

The question is incomplete. The complete question is :

Write a method that shuffles the rows in a two-dimensional int array using the following header: public static void shuffle(int[][] m)

Write a test program that shuffles the following matrix: int[][] m = {{1, 2}, {3, 4}, {5, 6}, {7, 8}, {9, 10}};

Solution :

//filename_suffle.java

#public class shuffle{

public_static_void_main_(String[] args) {

int[][] m = {{1, 2} {3, 4} {5, 6} {7, 8} {9, 10}};

System.out.println("Before shuffle");

displayMatrix(m);

System(dot)out(dot)println("After shuffle");

shuffle(m);

displayMatrix(m);

}

public_static_void_displayMatrix_(int[][] m) {

for (int i = 0; i < m.length; i++) {

for (int j = 0; j < m[i].length; j++) {

System.out.print(m[i][j] + " ");

}

System(dot)out(dot)println("");

}

}

public_static_void_shuffle_(int[][] m) {

int r1; // random row index

for (int i = 0; i < m.length; i++) {

for (int j = 0; j < m[i].length; j++) {

do {

r1 = (int)(Math.random() * m.length);

} while (r1 == i);

int[] temp = m[i];

m[i] = m[r1];

m[r1] = temp;

}

}

}

}

You might be interested in
Consider the following incomplete code segment, which is intended to increase the value of each digit in a String by one. For ex
arlik [135]

The instruction that should replace /* Missing Loop Header */ so that the code segment works as intended is (c)  counter < num.length()

<h3>Loops</h3>

The program is an illustration of loops (the while loop)

While loops are program statements that are used to perform repeated operations

For the string to return 23456, the while loop body must be repeated as long the counter is less than the length of the string num

Hence, the missing loop header is counter < num.length()

Read more about loops at:

brainly.com/question/15683939

7 0
3 years ago
A good place to get hints about how to answer a response question could be a. Your teacher c. Both of these b. The rest of the t
Julli [10]

i'm assuming the answer would be c- both of these

5 0
4 years ago
Read 2 more answers
5.23 LAB: Contains the character
torisob [31]

Answer:

In C++:

#include<iostream>

#include<vector>

using namespace std;

int main() {

int len;

cout<<"Length: ";  cin>>len;

string inpt;

vector<string> vect;

for(int i =0;i<len;i++){

  cin>>inpt;

  vect.push_back(inpt); }

char ch;

cout<<"Input char: ";  cin>>ch;  

for(int i =0;i<len;i++){

  size_t found = vect.at(i).find(ch);  

      if (found != string::npos){

          cout<<vect.at(i)<<" ";

          i++;

      }

}  

return 0;

}

Explanation:

This declares the length of vector as integer

int len;

This prompts the user for length

cout<<"Length: ";  cin>>len;

This declares input as string

string inpt;

This declares string vector

vector<string> vect;

The following iteration gets input into the vector

for(int i =0;i<len;i++){

  cin>>inpt;

  vect.push_back(inpt); }

This declares ch as character

char ch;

This prompts the user for character

cout<<"Input char: ";  cin>>ch;  

The following iterates through the vector

for(int i =0;i<len;i++){

This checks if vector element contains the character

  size_t found = vect.at(i).find(ch);  

If found:

      if (found != string::npos){

Print out the vector element

          cout<<vect.at(i)<<" ";

And move to the next vector element

          i++;

      }

}  

7 0
2 years ago
7. Type the correct answer in the box. Spell all words correctly.
____ [38]

Catherine's team is using the concept of on-off device by using a single transmitter to reach multiple receivers.

<h3>What is a device?</h3>

It should be noted that a device simply means something that is adapted for a particular purpose especially an electronic equipment.

In this case, Catherine's team is using the concept of on-off device by using a single transmitter to reach multiple receivers.

Learn more about device on:

brainly.com/question/24786034

7 0
2 years ago
Select the correct answer.
DochEvi [55]

Answer:

ask customers to use strong passwords to protect their accounts

6 0
3 years ago
Read 2 more answers
Other questions:
  • If you need to reprogramming your gps after you begin driving __.
    15·2 answers
  • What is the most widely used operating system for mobile devices?
    7·1 answer
  • After reading the article, "The Impact of Technology", answer the following question.
    14·1 answer
  • Create an array of strings. Let the user decide how big this array is, but it must have at least 1 element. Prompt them until th
    8·1 answer
  • What is the definition of D1-D4?
    14·1 answer
  • What includes two or more private, public, or community clouds, but each cloud remains separate and is only linked by technology
    11·1 answer
  • Active space is important in which type of photograph?
    12·2 answers
  • An array A[0..n - 2] contains `n-1` integers from 1 to `n` in increasing order. (Thus one integer in this range is missing.) Des
    11·1 answer
  • Is anyone a robIox moderator?
    13·2 answers
  • Assume variable age = 22, pet = "dog", and pet_name = "Gerald".
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!