Questions from Beginners MQL4 MT4 MetaTrader 4 - page 241
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
Hello programmers !
How to solve the comparison of two numbers in a for loop ?
What would it take to find A==B without the case of the loop i ?
In the loop compare two numbers is only on i, for example it compares them if i == 1 , then it only goes through the numbers A and B with the number that are equal to i .
I want it to try all of the given numbers with each other without the case of the cycle i. How to implement this in code, if you can show a code example.
Thank you.
Make a loop in the loop. First compare the first A with each of the ten B's, then the second A, etc.
Do a cycle in a loop. First compare the first A with each of the ten B's, then the second A, etc.
Thank you for your answer.
9 times? in this cycle 9 A, and 9 B .
I have a cycle of 100 A's and 100 B's and that's already going over each A and B.... 100 times. It's a nightmare.
There's no other way?
It all depends on the task at hand. It may be that you don't need to search for anything at all. For example, if some values are stored in an array beforehand.
What is required is not clear from your example so far. What are these comparisons for, what do you want to get?
It all depends on the task at hand. Maybe you don't need to search for anything at all. For example, if some values are stored in an array beforehand.
I have thought about it only with arrays I have a problem too old to understand them. But if an example was shown maybe I could figure out how to apply it. I thought about a two-dimensional array, but never got around to implementing it. The data is output the same in one-dimensional array as in loop....
I was thinking maybe someone has come across this and have a solution they could share.
It is still not clear from your example what is required. What are these comparisons for, what do you want to get?
In order to suggest something, you need to describe the problem. Not the solution, how you see it, but what you want to get out of it. Then you can think about the implementation.
In order to suggest something, you need to describe the problem. Not the solution, how you see it, but what you want to get out of it. Then we can think about the implementation.
Thank you, Aleksei, I will take your first advice, I have already implemented it. I just wanted to reduce the code, it was too much. I thought there was a simple solution, in private I have already been told that there is no other way.
In order to suggest something, you need to describe the problem. Not the solution, how you see it, but what you want to get out of it. Then we can think about the implementation.
I've been thinking, is it possible to do this by storing double data in the array? As far as I know, you can only put int into an array?
I think you could do something with this.......
In programming, there is rarely only one solution possible. There are always options. You don't say anything about meaning, so I don't know what to say.
An array can contain data of different types: