Home > Back-end >  C language and common elements of an array of multiple array and returns the common elements
C language and common elements of an array of multiple array and returns the common elements

Time:10-22

Encounter a problem, there is a line n * 2 d array arr [MAXnum], each line stored inside the mi (I represent the line Numbers) element, mi is a one-dimensional array m, how to write a function to find out all the common element, and the common element is returned as an array, seeks advice! Thank you very much!

CodePudding user response:

Sincerely, thank you

CodePudding user response:

Are stupid way is ordinal comparison, is to compare the first line element and the second row, found the first of the same element, and then compare the first and the third line of same element, if found in the third row of the same, as compared to the fourth row, or take a new element from the first line and second line, is to find the same (second) of the same and the third line element comparison, find the same compared to the fourth row, operation ~ in turn

CodePudding user response:

Reference the try https://blog.csdn.net/ParrySMS/article/details/78494882? Utm_medium=distribute. Pc_relevant_bbs_down. None - task - blog - baidujs - 2. Nonecase& Depth_1 - utm_source=distribute. Pc_relevant_bbs_down. None - task - blog - baidujs - 2. Nonecase

CodePudding user response:

reference 2 building self-confidence boy reply:
are stupid method is in turn, is to take the first line of the element and the second row, first find the same elements, and then compare the first and the third line of same element, if found in the third row of the same, as compared to the fourth row, or take a new element from the first line and second line, is to find the same (second) of the same and the third line element comparison, find the same compared to the fourth row, ordinal operation ~
this is about to take the meaning of the intersection, two comparison, finally get all lines of intersection?

CodePudding user response:

reference 4 floor Clutch_K response:
Quote: refer to the second floor confident boy reply:
are stupid method is in turn, is to compare the first line element and the second row, found the first of the same element, and then compare the first and the third line of same element, if found in the third row of the same, as compared to the fourth row, or take a new element from the first line and second line, is to find the same (second) of the same and the third line element comparison, find the same compared to the fourth row, ordinal operation ~
that is about to take the meaning of the intersection, two comparison, finally get all lines of intersection?

Well, the ~
  • Related