-
int a =;
int b =;
When the elements of A and B are the same, the index of A is recorded in the list.
listlistindex = new list();
for (int i = 0; i < i++)for (int j = 0; j < j++)if (b[i] == a[j])
break;
int c = new int[ -
int cindex = 0;
for (int i = 0; i < i++)if ( == false)
c[cindex] = a[i];
cindex++;
for (int i = 0; i < i++)
Array c is the result.
-
int a= ;
int b= ;
listar = new list();
for (int i = 0; i < i++)if (!
int arr = ;
arr This array is just the array you want.
It has been tested and passed and you can try it.
Actually, you can use lists, lists, which are very good, and the performance is much faster than arrays.
List is also more convenient to query with linq than with array.
-
Traversing the array elements to judge, using list or arraylist to assist int array1 = new int;
arraylist list1 = new arraylist();Store the remaining elements after deduplication.
arraylist list2 = new arraylist();Stores duplicate elements.
for (int i = 0;i < i++) Now the elements saved in list1 correspond to the array1 you need The elements saved in list2 correspond to the array2 you need If you want to convert to an array, you can use the built-in conversion methods such as loop assignment or list.
-
In this case, it is best to use list or arraylist(
It can also be made using arrays.
In addition, if it is only a single character, you can also use string to do it.
Only the solution to the list is given below. Write empty-handed, you can debug it yourself, but it's generally correct.
string array=new string
liststrlist0=new list();Raw data.
liststrlist1=new list();Array one, array1
liststrlist2=new list();Array two, array2
for(int i=0;i<;i++)
for(int i=0;i<;i++)
Array 2 is fetched using such an algorithm, if there is the same, then the addresses of indexof and lastindexof will be different, so it can be written like this.
for(int i=0;i<;i++)
If it's an int type, just change string to int.
Use loops to pay values to arrays.
-
It's very simple, you can use a collection or a dictionary.
Create a dictionary with numbers as keys and occurrences as values, iterate through the array, and if it is not in the dictionary, add it to the dictionary, and if it is in the dictionary, add one to the number of times.
int nums=;
dictionarydic = new dictionary();
for (int i = 0;i < i++) to set the number of occurrences to one.
else has this number, and the number of times is increased by one.
foreach (var item in dic);
-
I think of a dumber approach.
Create a new 2D Array 2, then iterate through your Array 1, match the first element of Array 1 with the other elements, and then put in Array 2.
Then you cycle and you get the result.
-
static void main(string args);For example, to find"ccc"In the index position of the array s for (int i = 0; i < i++)
-
It would be nice to extend the method with linq.
a = >i<7).toarray();
-
public void loadtxt()
It's okay to change it directly to the above **, there's no need to write so many versions. Right.
-
Randomly generate an array index with random, and then return the array elements.
-
Randomly generate an array index with random, and then return the array elements.
If it's a hard disk version of ghost, just restore it directly. >>>More
There are two kinds of self-increment and self-reduction, one is the forward fall (++i,--i), and one suffix (i++, i--) There is a big difference between the two, and the prefix self-increment and self-decrease is to run itself first, and then run others. The suffix is self-incrementing and self-decreasing, which is to run the other first in the run itself. >>>More
Your anomaly was triggered, but it was eaten.
Because the using statement is actually try....Finally, your ** is equivalent to. >>>More
First of all, if you are wrong, if the value type is a global or static variable, it is assigned on the heap, and the local variable is allocated on the stack. The reference type is allocated on the heap, because the new comes out of the dynamically allocated memory, so both local and global are in the heap until the garbage user goes to it. In fact, memory allocation is basically the same form, and it has nothing to do with the language.
1.White's Leg + Omniscient Potion + 1000 Return to the City (can bring troops back to the City with you) [Dot-legged roars, so .......]] >>>More