5 Replies - 155 Views - Last Post: 20 October 2019 - 09:05 AM Rate Topic: -----

#1 teasu873   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 20-October 19

Array to array assigning with sorting

Posted 20 October 2019 - 08:38 AM

It's a very easy task, but for some reason I cannot do it, I'm trying to do it for many hours already, help me please.

Make a function that has as its parameters length of 2 arrays and these 2 arrays too. It needs to assign all nonzero values from 1st array to 2nd, from left to right in ascending order and return number of significant ( that were assigned to 1st to 2nd ) elements of 2nd array.
Prototype:
size_t counter(size_t length, int input[length], int output[length]);


If it was not understandable I'll give an example.

input {1, 4, 0, -6, 0} --> output {-6, 1, 4, trash, trash}
return 3


The problem that, is I'm stuck on assigning elements from 1st do 2nd, I just cannot figure out how to do it normally, without very long and hard methods

Is This A Good Question/Topic? 0
  • +

Replies To: Array to array assigning with sorting

#2 Salem_c   User is offline

  • void main'ers are DOOMED
  • member icon

Reputation: 2397
  • View blog
  • Posts: 4,530
  • Joined: 30-May 10

Re: Array to array assigning with sorting

Posted 20 October 2019 - 08:44 AM

Also here -> https://cboard.cprog...-cannot-do.html
Was This Post Helpful? 1
  • +
  • -

#3 modi123_1   User is online

  • Suitor #2
  • member icon



Reputation: 15359
  • View blog
  • Posts: 61,588
  • Joined: 12-June 08

Re: Array to array assigning with sorting

Posted 20 October 2019 - 08:58 AM

Array assignment is tripping you up?

As in:

ArrayOne[0] = ARrayTwo[0];

Was This Post Helpful? 0
  • +
  • -

#4 teasu873   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 20-October 19

Re: Array to array assigning with sorting

Posted 20 October 2019 - 08:59 AM

I'm just finally managed to do it, solving was so close that I needed to add less than 15 symbols, thanks everyone.
Was This Post Helpful? 0
  • +
  • -

#5 modi123_1   User is online

  • Suitor #2
  • member icon



Reputation: 15359
  • View blog
  • Posts: 61,588
  • Joined: 12-June 08

Re: Array to array assigning with sorting

Posted 20 October 2019 - 09:02 AM

What did you end up doing?
Was This Post Helpful? 0
  • +
  • -

#6 teasu873   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 20-October 19

Re: Array to array assigning with sorting

Posted 20 October 2019 - 09:05 AM

View Postmodi123_1, on 20 October 2019 - 09:02 AM, said:

What did you end up doing?

I moved counter of valuable numbers to cycle that is copying numbers from 1st to 2nd without sorting and then made bubble cycle repeat less times with counter.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1