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
Maurinko [17]
3 years ago
12

Write a method with the header public static void swapAdjacent(int[] values) that takes a reference to an array of integers valu

es and swaps adjacent pairs of elements: values[0] with values[1], values[2] with values[3], etc. For example, if you add the following test code to your main method: int[] a1 = {0, 2, 4, 6, 8, 10}; swapAdjacent(a1); System.out.println(Arrays.toString(a1));
Computers and Technology
1 answer:
andreev551 [17]3 years ago
3 0

Answer:

public static void swapPairs(int[] a){

   int len=a.length;

       if(len%2 ==0){

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

               a[i]=a[i+1];

               a[i+1]=a[i];

               int[] b={a[i]+a[i+1]};

           }    

       }

       if(len%2 !=0){

           for(int j=0; j<len; j=j+2){

               a[j]=a[j+1];

               a[j+1]=a[j];

               a[len-1]=a[len-1];

               int[] b={a[j]+a[j+1]+a[len-1]};

           }

       }    

}

public static void printArray(int[] a){

   System.out.println(a);

}

You might be interested in
If I want to add a new slide to my presentation, which option would I click on?
ivanzaharov [21]
The answer would be D. New Slide
3 0
2 years ago
Handhed computer is otherwise called as<br> 1.laptop<br> 2.Notebook<br> 3.Palmtop
NikAS [45]

Answer:

personal digital assistants (PDAs)palmtop

3 0
3 years ago
Analizar los componentes de una computadora completa hoy en día comparada con el inicio de la Informática.
scZoUnD [109]

Answer:

Explanation:

Las computadoras que existian en el inicio de la informatica y las que existen ahora tenian los mismos componentes. Estos eran CPU, Placa Madre, RAM, HDD, y tarjeta grafica. Lo que si cambio fueron el velocidad y capacidad. Por ejemplo, en el inicio las Tarjetas de RAM venian como DDR a una velocidad maxima de 133 Mhz con una capacidad de entre 4mb y 8mb. Hoy en dia tenes RAM de DDR5 con una velocidad de 4400 Mhz y de 8gb. Mientras que avanzaba el tiempo los componentes de las computadoras aumentaban en velocidad y capacidad aunque el tamaño bajaba o aumentaba dependiendo del gusto del usario.

8 0
2 years ago
What is the output from this program? #include void do_something(int *thisp, int that) { int the_other; the_other = 5; that = 2
Ostrovityanka [42]

Answer:

  1  35

Explanation:

* There is a little typo in printf. It should be "\n".

Initially, the value of the first is 1, and the value of the second is 2. Then, do_something(&second, first) is called. The value of the <em>first</em> will still be 1. However, there is a call by reference for <em>second </em>variable. That means the change made by the function <em>do_something</em> will affect the value of the <em>second</em> variable.

When you look at the calculation inside the <em>do_something</em> function, you may see that value of the <em>second</em> will be 35.

7 0
3 years ago
Select the properties of the sn1 reaction mechanism.
musickatia [10]

It is - not stereospecific , a reaction in which the stereochemistry of the reactants controls the outcome of the reaction; - bimolecular at rate-determining step , it involves two molecules; - first order, - rates is governed by the stability of the carbocation that is formed.

7 0
2 years ago
Other questions:
  • What is the output of the following program?
    8·1 answer
  • How to turn a flash drive into a bluetooth adapter?
    13·1 answer
  • What are the design concepts and assumptions behind a class, an object and the relationship between them? What are the roles met
    9·1 answer
  • Misperceptions can lead to miscommunication. List an example from the article.(site 1)
    10·2 answers
  • PLEASE HELP. I’ll mark you BRAINLIST <br> Please read the comment under this question
    9·1 answer
  • Explain the following terms <br><br>copyleft:<br><br>creative Commons:<br><br>GNU/GPL:​
    8·1 answer
  • Complete the sentence.<br> Python is a_____<br> level language compared to bytecode.
    7·2 answers
  • Jason is the motion picture projectionist at the local IMAX theater. This means that he runs the huge movie projector so that cu
    12·1 answer
  • Wirte a program which asks the users to input length and calculates the area of a square.( Area = Length^2)​
    14·1 answer
  • Assume the name of your data frame is flavors_df. What code chunk lets you review the structure of the data frame?
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!