Rearranges an integer array

Assignment Help Basic Computer Science
Reference no: EM132130595

***C PROGRAMMING***

Need help with a C program array_rearrange.c that rearranges an integer array. The array will be split into two sets of integers one by one. A new array will be created by append the first set to the second set. For example, an integer array {1, 2, 3, 4, 5, 6} will be split into two sets of integers: 1, 3, 5 and 2, 4, 6. Merging result: {2, 4, 6, 1, 3, 5}. Note that the two sets do not necessarily have the same length (when the array has even number of elements). When the input word has odd number of elements the first set will be one element more than the second set. For example, the result of rearranging an integer array {1, 2, 3, 4, 5} will be {2, 4, 1, 3, 5}. Your program should include the following function: void rearrange(int *a1, int n, int *a2); 

The function should use pointer arithmetic - not subscripting - to visit array elements. The rearrange function merges the two sets of integers by appending the first set to the second set and store the result in the second array a2. The function takes an int array parameters a1 and 2 as the first parameter and third parameters and the number of elements of the arrays as the second parameter.  

Example I/O:

Enter the length of the array: 5 

Enter the elements of the array: 9 8 5 6 4 

Output: 8 6 9 5 4

Reference no: EM132130595

Questions Cloud

What is the effect of association with criminals in jail : What is the effect of association with criminals in jail and prison? Do peer associations among juveniles assist in the development into criminal lifestyles?
Find minimal dfa : Find minimal dfa's for the following languages. In each case prove that the result is minimal.
Examine ucr statistics related to property crimes : Rates of property crime have risen and fallen over time. Examine UCR statistics related to property crimes. How have crime rates changed over time?
Examine each of the given profit growth scenarios : The head of the accounting department at a major software manufacturer has asked you to put together a pro forma statement of the company's value under several.
Rearranges an integer array : Need help with a C program array_rearrange.c that rearranges an integer array. The array will be split into two sets of integers one by one.
Positive numbers in the array a and store : The extract function finds the positive numbers in the array a and store in array positive. The third parameter is array of positive numbers
Discuss some of the differences in legal definitions : The one unique characteristic with juvenile delinquency is that the legal definition will vary from one state to another.
Assignment on information systems audit and controls : Elaborate on the different types of control that are applied in a hospital (Preventive, detective and corrective control).
How necessary and effective are elite counterterrorism units : What other counterterrorist options do you think may be effective without resorting to the deployment of elite units?

Reviews

Write a Review

Basic Computer Science Questions & Answers

  Provide a web page with a simple calculator

Provide a web page with a simple calculator. The web page will have two text boxes (with labels) for data entry, radio list box to select.

  Contribute to slowing disk performance

What do you think are some of the main things that contribute to slowing disk performance? How might you address these issues?

  Key factors for future competitive success

Discuss with your class the key factors for future competitive success. List the common types of key success factors and answer the following questions:

  Identify commonly used antivirus software packages

Identify three commonly used antivirus software packages. Develop a spreadsheet that compares the cost and fundamental features of each package.

  Purchasing and materials management

To a great extent, purchasing and materials management is becoming a strategic business function. Explain why this is true. (150-200 words)

  Group policy on windows servers

1. What are some of the advantages of using Group Policy? What are some of the things that can be managed with it?

  Make report to print gross earnings and tax payable

Your report is to print the gross earnings, tax payable, medical levy and net earnings for each employee. At the end of the report, print the total gross earnings, total tax, total medical levy and total net earnings.

  Holdings of government securities

If, in a particular year, the government ran a budget deficit of $200 billion and the private sector's holdings of government securities increased by $100

  Using disappointment theory

Using disappointment theory, what would Kyle choose among the following options:

  Verify local police department-s findings on firm-s case

Tension over case is running high in city. What do you require to ask police investigator for, and what procedures must you follow?

  Layer of the osi does stp belong in to

What layer of the OSI does STP belong in to. Will you need STP if your network is designed and implemented only using routers,and no witches at all?

  Fairness of arbitration procedures

Ex Parte communication is a major concern in the fairness of arbitration procedures and can result in the overturning of an award if proven.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd