Any questions from newcomers on MQL4 and MQL5, help and discussion on algorithms and codes - page 141
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Friends, I've been working too hard...
Here's the question: There is an array of, say, four numbers. We need to find out the number of equal numbers in the array.
1,2,3,4 - no identical numbers
1,1,2,3 - two same numbers
1,1,2,2 - also two identical numbers.
1,2,1,2 - there are two identical.
1,1,1,2 - three alike
1,1,1,1,1 - four of them are the same.
It doesn't seem complicated, but I can't think of anything...
HOW?
Friends, I've been working too hard...
Here's the question: There is an array of, say, four numbers. We need to find out the number of equal numbers in the array.
1,2,3,4 - no identical numbers
1,1,2,3 - two same numbers.
1,1,2,2 - also two identical numbers.
1,2,1,2 - there are two similar ones
1,1,1,2 - three alike
1,1,1,1,1 - four of them are the same.
It doesn't seem complicated, but I can't think of anything...
HOW?
if (ArraySort(Array))
{
int Tmp = 1;
for (int i = ArraySize(Array) - 1; i > 0; i--)
{
if (Array[i - 1] != Array[i])
{
if (Tmp > Res)
Res = Tmp;
Tmp = 0;
}
Tmp++;
}
}
if (ArraySort(Array))
{
int Tmp = 1;
for (int i = ArraySize(Array) - 1; i > 0; i--)
{
if (Array[i - 1] != Array[i])
{
if (Tmp > Res)
Res = Tmp;
Tmp = 0;
}
Tmp++;
}
}
Yeah, I'll have a look. Thank you. I get the idea
Just got my horn in the simple, doing the complex ....
Arrange the array and do a comparison with the current value and the past value, if matched, then counted - or I don't understand the question.
Thanks. Just a bit wrong - there may be several matching but different numbers between them.
definitely worked out :-)
Thanks. Just a bit wrong - there may be several matching but different numbers.
The problem needs to be defined more clearly.
1) A number is given as input and you want to output how many matches there are for that number in the array.
2) Or do you want to output all the numbers that are duplicated in the array?
You need a clearer definition of the problem.
1) A number is given as input and you want to output how many matches there are for that number in the array.
2) Or do you want to output all the numbers that are duplicated in the array?
Neither of them.
There are four known unknown numbers. You need to find the number of duplicate numbers as in the example in my first post.
definitely worked out :-)
Yeah, well... Worked out :))
I don't know what to call these numbers: 1,1 2,2 ... or 1,2,1,2 - here the number (result) is 2
repeated (1,1)... but different(1,1,2,2) ... - and here the number (result) is 2
And how do I call it correctly - I don't know - I'm not a client, though
ZS. By the way - repetitive - that's me for nothing... Otherwise you might think that "going in a row"... That's not necessary.
Just the number of matching numbers. Although that might not be the right way to put it either... yes... it's a hard life for the customer...
I don't know what to call it - I'm not a customer, though.
The maximum number of identical values in a sequence?
Nope :)))
1,1,1,2,3,3,2,1,4,4,5
is the number of numbers of the same colour.