Ask an algorithm question. Take a number from each array to form a new array. How many combinations are there?

for example, there are two arrays, one number for each group, and a new array according to size,.
if size is 2, then the result is [1pje 1], [1p3], [1p4], [2pr 1], [2pr 3], [2pr 4], [3pr 1], [4pr 1], [2pr 1], [3jue 2], [4jue 2]];
if size is 3, the result is [1pr 1 parol 3], [1je 1pr 4], [1je 3pr 4]. And so on]
is probably a function fun (arr1,arr2,size) and then gets a new array


 

throw them into a set, and all that's left is the question of how many size arrays n non-repeating numbers can form.
that is, (n-size+1) * (n-size) / 2

< hr >

well, if you look at it carefully, there are two steps. The first step is to split the size, first and then to take the number
. The above algorithm can still be applied. The split algorithm is also better to achieve the
general steps:
calculate shorter, longer array length, write it down as min,max
, then compare min with size, and take the smaller (flag)
as the critical value. The rest is to take the number of flag from the min length array. Take the number of size-flag from max
and then the logical judgment of flag--
is a little more detailed. That's probably the way of thinking

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b30732-2bd0b.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b30732-2bd0b.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?