Home > Software engineering >  [for] (VB) digital grouping problem
[for] (VB) digital grouping problem

Time:12-22

Example:
1, 2, 3, 4, 5 group
The first kind of grouping [1, 2] [3] [5]
The second type of grouping 4-trichlorobenzene [1] [3, 4] [5]
The third type of grouping, 4-trichlorobenzene [2] [3, 5]
Every number can only appear in a category, number cannot repeat in each group, digital part finished, all meet the conditions of grouping is, 4-trichlorobenzene [1] [3, 5)
Digital number for M, category of N, number of each category grouping, for the first meet the conditions of grouping,

CodePudding user response:

The first kind of plan
1, Numbers in an array,
2, according to the group number, generating random Numbers, such as 3 groups, randomly generated 1, 2, 3
3, each generates a set of Numbers, from an array of Numbers 1 a,
4, until you get,

The second kind of plan
1, Numbers in a two-dimensional array of the first dimension,
2, 2 d value for the loop to generate two-dimensional array, such as 3 groups, randomly generated 1, 2, 3
3, according to the values in the two-dimensional, loop output,

CodePudding user response:

You want elements to be grouped, or judgment on existing grouping meet the conditions? If the latter, how the group submitted?

Grouping "class" what are the rules? A single element of "group" is it legal? The biggest packet can contain several elements?

CodePudding user response:

You this question, only said a "solution" :
 
//level 1 cycle: iterate over all "classified"
{
//put to judge the data in a "temporary array", for example, if you say "1, 2, 3, 4, 5
"//with a variable count: the variable 0
//layer 2 cycle: iterates through all the grouping "classification"
{
//layer 3 cycle: traverse elements of each group may have to use 4 layer circulation,
//determine whether each grouping element exists in "temporary array"
If (within the temporary array)
{
//variable CNT + 1
//put the element removed from the "temporary array"
}
The else
{
//jump out of the third layer, layer 2 cycle (note: methods and processes)
}
}//layer 2 cycle end
If (variable CNT==number of data)
{
//"classification" meets the requirements
}
The else
{
//"classification" is not in conformity with the requirements of
}
}
//other subsequent processing

CodePudding user response:

According to the above process:
If any one category of "packet data duplication," or "no data points out,"
Will appear to count "variable" indicates the result of "data number",
  • Related