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
omeli [17]
4 years ago
14

Write a method named swapAll that accepts two arrays of integers as parameters and swaps their entire contents. You may assume t

hat the arrays passed are not null and are the same length. For example, if the following arrays are passed:int[] a1 = {11, 42, -5, 27, 0, 89};
int[] a2 = {10, 20, 30, 40, 50, 60};
Computers and Technology
1 answer:
vodomira [7]4 years ago
7 0

Answer:

void swapAll(int *a1, int *a2, int n){

int i;

int tmp[n];

for(i = 0; i < n; i++){

tmp[i] = a1[i];

a1[i] = a2[i];

a2[i] = tmp[i];

}

}

Explanation:

You just need a temporary structure.

I am going to write a c script, in which a1 and a2 are the arrays and n is the length of the arrays.

void swapAll(int *a1, int *a2, int n){

int i;

int tmp[n];

for(i = 0; i < n; i++){

tmp[i] = a1[i];

a1[i] = a2[i];

a2[i] = tmp[i];

}

}

You might be interested in
A "want" is very different than a "need'. What is a want?
Snowcat [4.5K]
I miss read the question the first time....the answer is C.
8 0
4 years ago
Read 2 more answers
Suppose you have 9 coins and one of them is heavier than others. Other 8 coins weight equally. You are also given a balance. Dev
sergey [27]

Answer:

Following are the algorithm to this question:

Find_Heavier_Coins(Coin[9]):

   i) Let Coin[] Array represent all Coins.  

   ii) Divide coin[] into 3 parallel bundles and each has three coins, example 0-2, 3-5, 6-8 indicate a1 a2 a3

   iii) Randomly select any two bundles and place them in balance [say a1 and a2]

   iv) If Weigh of a1 and a2 has same:

           // checking that if a3 has heavier coin

           Choose any two 6-8 coins and place them onto balance [say 6 and 8]

           If those who weigh has the same weight:

               Third coin is coin heavier [say 7]

           else:  

               The coin [6 or 8] is the one which is heavier on the balance

       else:

           //The coin has the package which would be heavier on the balance [say a1]

           Select any two coins on balance from of the heavier package [say 0 and 1]

   If they weigh the same weight:

       Third coin is coin heavier [say 2]

   else:

       The coin that is heavier on the balance is the [or 0]

Explanation:

In the above-given algorithm code, a method Find_Heavier_Coins is declared which passes a coin[] array variable in its parameters. In the next step, if conditional block is used that checks the values which can be described as follows:

  • In the first, if block is used that checks a1 and a2 values and uses another if block in this it will print a3 value, else it will print 6 to 8 value.
  • In the another, if the block it will check  third coins value and prints its value if it is not correct it will print first coin value
4 0
4 years ago
Bbbbbbbbbbbbbbbbbbbbbbbb
ira [324]

Answer:

ccccccccccccccccccccccccccccccccccccccccccccccc?

5 0
3 years ago
Read 2 more answers
A data analyst is working with a
ELEN [110]

The code chunk that is going to let this data scientists to do this is

  • unite(retail, “price”, price_dollars, price_cents, sep=”.”)
  • Option C

<h3>What is a code chunk in R</h3>

These are the means that are helpful for rendering the outputs that are in the R programming language to documents.

The chunk can help to show the written code for the sake of illustration.

<h3>Complete question</h3>

Please Choose The Correct Option ✔

A

unite(retail, price_dollars, price_cents, sep=”.”)

B

unite(retail, “price”, price_dollars, price_cents)

C

unite(retail, “price”, price_dollars, price_cents, sep=”.”)

Correct Answer

D

unite(retail, “price”, price_cents, sep=”.”)

Read more on R codes here:

brainly.com/question/26253705

7 0
2 years ago
Dеclarе and allocatе mеmory (on thе hеap) for a onе-dimеnsional array of 256 doublеs namеd pricеs
Zigmanuir [339]

Answer:

double *prices=new double [256];

Explanation:

To allocate memory on heap we use new keyword.In the above statement an array name prices is declared and the memory allocated to it is on the heap memory.

First look at double * prices.It is a pointer this pointer is created on the stack memory which holds starting address of the array present on the heap memory of size 256..

4 0
3 years ago
Other questions:
  • If you receive an increase in pay, how will that affect your payroll deductions?
    8·1 answer
  • What is the difference between First Person Shooters and Construction Simulations?
    12·2 answers
  • In Windows-based systems, a value that specifies the rights that are allowed or denied in an access control entry (ACE) of an ac
    14·1 answer
  • 2. Name the layer of the Web/Internet Protocol Stack with which each of these functions is associated.
    10·2 answers
  • In 1-2 sentences, describe some keyboard shortcuts you have used during this lesson to save you time.
    13·2 answers
  • While typing out his assignment henry makes use of leading. What could be the probable reason for him to do so.
    9·2 answers
  • A page-ranking algorithm ranks web pages according to
    15·2 answers
  • Given a Scanner reference variable named input that has been associated with an input source consisting of a sequence of lines,
    13·1 answer
  • What layout manager should you use so that every component occupies the same size in the container?
    5·1 answer
  • (I'm confused, might as well ask for help)
    8·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!