Answered You can hire a professional tutor to get the answer.

QUESTION

Hi, can you help me with this question in C programming?

Write a program vector_permutation. c that:. reads a positive integer n. reads n integers po P1 ... Pn - 1reads n integers q0 91 ... An - 1checks qo ... On - 1 are non-negative integers less than n. prints Pag Pq1 ... Pan - 1In other words the first n integers, PO P1 ... Pn-1 specify a vector.The second n integers, q0 91 ... On-1, specify how that vector should rearranged.So for example if the vector has 5 elements and qo q1 ... qn-1 are 0 1 2 3 4 thenthe vector will be unchanged.And if qo q1 ... qn - 1 are 4 3 2 1 0 then the vector will be reversed.Match the example output below EXACTLY:: doc -o vector_permutation vector_permutation.c./vector_permutationEnter vector length: 4Enter vector: 42 43 44 45Enter permutation: 3 1 2 045 43 44 42: ./vector_permutationEnter vector length: 6Enter vector: 40 41 42 43 44 45Enter permutation: 0 1 2 3 4 540 41 42 43 44 45: ./vector_permutationEnter vector length: 6Enter vector: 40 41 42 43 44 45Enter permutation: 5 4 3 2 1 045 44 43 42 41 40: ./vector_permutationEnter vector length: 1Enter vector: 1024Enter permutation: 01024./vector_permutationEnter vector length: 5Enter vector: 48 36 48 24 12Enter permutation: 4 3 1 0 212 24 36 48 48In all the examples above, qo q1 ... On is a permutation of the integers 0..n-1.You don't have to check this is the case.However you do have to to check q1 ... On are all > = 0 and < n.Match the example output below EXACTLY:: ./ vector_permutationEnter vector length: 5Enter vector: 48 36 48 24 12Enter permutation: 4 3 5 0 2Invalid permutationHint: use an arrays to store the vector and an array to store the permutation

Show more
LEARN MORE EFFECTIVELY AND GET BETTER GRADES!
Ask a Question