Advertisement
Guest User

Untitled

a guest
Nov 19th, 2017
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.83 KB | None | 0 0
  1. /*______________________________________________________________________________________
  2. Function: getDuplicateValues
  3. Description: inputs one array, and outputs all repeated values into another array
  4. Arguments:
  5. arrayData1[] (I) - The array that inputs to function.
  6. arraySize1 - The size of the input array.
  7. arrayData2[] (O) - The array that outputs from function.
  8. Return Value: int
  9. ________________________________________________________________________________________*/
  10. int getDuplicateValues(int arrayData1[], int arrayData2[], int arraySize1) {
  11. int duplicateNum = 0;
  12. for (int x = 0; x < arraySize1; x++)
  13. {
  14. for (int z = x + 1; z < arraySize1; z++)
  15. {
  16. if (arrayData1[x] == arrayData1[z])
  17. {
  18. duplicateNum++;
  19. arrayData2[x] = arrayData1[z];
  20. break;
  21. }
  22.  
  23. }
  24. }
  25.  
  26. return duplicateNum;
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement