Home > Software engineering >  A one-dimensional array assignment, how to ensure that all of the assignment are not identical, set
A one-dimensional array assignment, how to ensure that all of the assignment are not identical, set

Time:11-30

One dimensional array assignment, how to ensure that all of the assignment is not the same, how to set up inspection condition? Thank you very much!

CodePudding user response:

To be "different", in addition to the one by one to check whether "and" before some element value of the "duplicate", which will there be any other way!

"Array" is itself does not support any "Settings", if you want to have what condition, that you have to write their own code realization,



(feel the building seems to don't understand the concept of programming!)

CodePudding user response:

Thank you for your reply, I really not strong programming basis, but I want to ask is how to implement with code, I know that the array can't check, I just can't write a check input code?

Thank you very much!

CodePudding user response:

The problem is that your "array element" is what kind of things?
Is a numerical or text? Or is "object"?
If it is "value", the range is "wide" or "narrow"?
For different things, the processing method is not the same;
Especially in "wants be particular about code quality and efficiency", but also should be kept separate,

Check whether "repeat", if you want to simple point "" code, you can use a Dictionary object,
But this object does not fit the data volume is too big, too much data speed decreases obviously,
I've tested several years ago:
Will be about 30000, slow to follow "own to find in the 'orderly array" about the same, the speed of the
More than 50000, has been significantly slower than "find their own" also,
Of course, if the "speed" is not very demanding, or the amount of data is not much, use Dictionary object is a good choice,

CodePudding user response:

A speculative way:
A new collection, and then the element to add, at the same time the element value as the key value to fill in, if it is pure numerical, adding a string prefixes what), when there are duplicate data, add failed can be repeated as key,

CodePudding user response:

Must be repeated random, the so-called "no" is actually a shuffle, repeat random shuffle algorithm is used to refer to the following (albeit not VB) C:
 # include & lt; Stdio. H> 
#include
#include
Int d [6];
Int I, n, a, b, t;
C, int j;
Void main () {
Srand (time (NULL));
Printf (" shuffle 0.. N - 1 demo \ n ");
For (n=1; N<=5; N++) {/* (1 ~ 5 */
Printf (" _____n=% d_____ \ n ", n);
j=1;
For (c=1; c<=n; C + +) j=j * c;/* j for n! */
J *=n * 2;
For (c=1; c<=j; C + +) {/* test n * 2 * n! Time */
for (i=0; iFor (I=n; i> 0; I -) {/* disturb 0 ~ */n - 1
A=I - 1; B=rand () % I;
If (a! A=b) {t=d [a]; D [a] [b]=d; D [b]=t; }
}
Printf (" % 4 d: ", c);
for (i=0; iprintf("\n");
}
}
Printf (" shuffle 1.. N demo \ n ");
For (n=1; N<=5; N++) {/* (1 ~ 5 */
Printf (" _____n=% d_____ \ n ", n);
j=1;
For (c=1; c<=n; C + +) j=j * c;/* j for n! */
J *=n * 2;
For (c=1; c<=j; C + +) {/* test n * 2 * n! Time */
for (i=1; i<=n; I++) d [I]=I;/* fill in 1 ~ n */
For (I=n; i> 1; I -) {/* disturb 1 ~ n */
a=i; B=rand () % I + 1;
If (a! A=b) {t=d [a]; D [a] [b]=d; D [b]=t; }
}
Printf (" % 4 d: ", c);
for (i=1; i<=n; I++) printf (" % d ", d [I]);
printf("\n");
}
}
}

CodePudding user response:

The ListBox depositing the array, if you don't want the user to see, can be set to invisible,

 Private Declare Function SendMessagebyString Lib "user32" Alias "SendMessageA" (ByVal hWND As Long, _ 
ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long As String)

Private Const LB_FINDSTRINGEXACT=& amp; H1A2 'precise search in the ListBox
Private Const CB_FINDSTRINGEXACT=& amp; H158 'precise search in the ComboBox
Private Const LB_FINDSTRING=& amp; H18F 'in the ListBox fuzzy search
Private Const CB_FINDSTRING=& amp; H14C 'in the ComboBox fuzzy search

Private Sub Command1_Click ()
If 1=SendMessagebyString (List1. HWnd LB_FINDSTRINGEXACT, 1, Text1. Text)
List1. AddItem Text1. Text
End the If
End Sub

Read, read a List item List1. List (x),

CodePudding user response:

Heard that easy language there is this functionality, you go to try it on
  • Related