Guest User

Untitled

a guest
Apr 21st, 2018
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.67 KB | None | 0 0
  1. int inputarray[50] = {1,2,3,4,5}; // etc etc etc
  2.  
  3. int outOdds[50] = {-1}; // init them all to -1
  4. int outEvents[50] = {-1};
  5.  
  6.  
  7. void doSomething( int* arrayOdds, int* arrayEvens )
  8. {
  9. // no idea what your totalling stuff is supposed to do but heres how you access the arrays:
  10. for (int i=0; i<50; i++)
  11. {
  12. cout << arrayOdds[i];
  13. cout << arrayEvens[i];
  14. }
  15. }
  16.  
  17.  
  18. void main()
  19. {
  20. int oddsIter = 0;
  21. int evensIter = 0;
  22.  
  23. for (int i=0; i<50; i++)
  24. {
  25. if (inputarray[i] % 1 == 0)
  26. {
  27. outOdds[oddsIter] = inputarray[i];
  28. oddsIter++;
  29. }
  30. else
  31. {
  32. outEvens[evensIter] = inputarray[i];
  33. evensIter++;
  34. }
  35. }
  36.  
  37. doSomething(outOdds, outEvens);
  38. }
Add Comment
Please, Sign In to add comment