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
zhuklara [117]
3 years ago
10

Write a static method reOrder56(int[] nums) that return an array that contains exactly the same numbers as the given array, but

has been reorderd so that every 5 is immediately followed by a 6. You may choose to move every other number with the exception of 5; You are not to move 5. The array contains the same number of 5's and 6's, every 5 has a number after it that is not a 5, and a 6 appears in the array before any 6.
Computers and Technology
1 answer:
denpristay [2]3 years ago
8 0

Answer:

Follows are the code to the given question:

static int[] reOrder56(int[] nums)//defining a static method reOrder56 that holds an array in parameter

{

   int x,y;//defining integer variables

   for(x=0;x<nums.length;x++)//using for loop that counts array  

   {

       if(nums[x]==5 && nums[x+1]!=6) //defining if block checks arry values

       {

           for(y=0;y<nums.length;y++)//use for loop to count array value again  

           {

               if(nums[y]==6 && nums[y-1]!=5)//defining if block checks arry values  

               {

                   nums[y] = nums[x+1];//swap the array element value

                   nums[x+1] = 6;//holing value in array

                   break;//break the condition

               }

           }

       }

   }

}

Explanation:

In this code, a static method "reOrder56" is declared that takes an integer array "nums" in its parameter, and inside the method, two integer variable "x, y" is defined, which is used in the nested loop.

In the first loop, it holds array values and uses the if block to check the array element value and define another loop to check the same condition, and this block, swap the value and holds the value in the array and breaks the condition.

You might be interested in
If you wish to maintain a consistent style to all the documents you create, it would be helpful to use a _____.
Ket [755]

Hey!

Hope this helps...

~~~~~~~~~~~~~~~~~~~~~~~~~

It would be helpful to use a: template

This keeps the fonts, colors, background, headers, footers, all the same in any (or all) the documents you create that you want to look like in a certain way...

6 0
3 years ago
What do we call a subset of new media in which groups and their fans can interact directly?
ser-zykov [4K]
<span>A subset of new media in which groups and their fans can interact directly is referred to as social media.
</span>Social media is a computer-based technology that can p<span>rovide radically different social actions.Examples include: twitter, instagram, facebook.
</span>Social media is very influential so it is becoming a very important part of marketing.
5 0
3 years ago
Why would an over the shoulder shot be used
Nezavi [6.7K]
To capture a certain size frame of the persons face mainly to emphasize on who is talking
3 0
3 years ago
Write a pseudocode to calculate the volume of a cylinder​
Alinara [238K]

Answer:

10.50, height = 15.01, and pi = 3.1415.

7 0
3 years ago
The World Wide Web is full of unstructured data. Search engines like Google, Bing and Yahoo have been doing a good job of allowi
bija089 [108]

Answer: Query

Explanation:

The Search Criteria is entered and any when a related Query is logged, it speedily bring out the linked details for exploration.

5 0
3 years ago
Other questions:
  • What does CPL stand for
    9·2 answers
  • The computers that run the DBMS and all devices that store database data should reside in locked, controlled-access facilities.
    15·1 answer
  • What are you guys doing?
    13·2 answers
  • What is the most consistent item regardless of the software used in BI?
    5·1 answer
  • When Web users enter the URL www.CIWcertified.com in their browser address bar, they can access the official CIW Web site at the
    6·2 answers
  • A user is attempting to format a 4 TB HDD using NTFS but only has the option to format the disk with a size of approximately 2 T
    15·1 answer
  • Fact about energy that will make a knex car move
    7·2 answers
  • To access your gradebook you click on the __________.
    6·2 answers
  • You are splitting up all your apples equally between 3 people. which statement below will calculate how many apples will be left
    12·1 answer
  • me pueden ayudar con mi trabajo sii porfss si me dan la respuesta correcta y les doy la mejor coronita si​
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!