if(true) - page 7

 
There was a time, there was a competition...
 
Nostalgia?
 
Алексей Тарабанов:

Maxim, it doesn't work that way, there should be 2 cycles, otherwise there is no way. First you remove unnecessary elements, then you "shrink" the array upwards (float). The second loop is inside the first one.

No, his algorithm is correct, just slow. There was a small mistake.
corrected and simplified:

int ArrayDeleteVal3(int &arr[],int val)
  {
   int size=ArraySize(arr);
   int count=0;   // кол-во удалённых
   for(int i=0;i<size;i++) {
      if (arr[i]==val) count++;
      else arr[i-count]=arr[i];
   }
   ArrayResize(arr,size-count);
   return size-count;
  }
 
Алексей Тарабанов:
Nostalgia?

Boring. There's not enough competition.

 
Реter Konow:

Boring. There's not enough competition.

Let's make up a competition.

For example, write the fastest code for a simple robot. Or the shortest robot code.

Suggest your options.

 
Sergey Chalyshev:

Let's think of a competition.

For example, write the fastest code for a simple robot. Or the shortest robot code.

Suggest your options.

Write a robot that sorts history bars by their parameters inside arrays. The values of the parameters of the bars, which are closer to each other, get to one group. The robot should automatically determine the number of groups, create them and sort out the bars indexes by them. For example.

Как заказать торгового робота на MQL5 и MQL4
Как заказать торгового робота на MQL5 и MQL4
  • www.mql5.com
Главным преимуществом торговых терминалов MetaTrader является возможность создания автоматических торговых систем, способных совершать торговые операции без вмешательства трейдера, что позволяет исключить влияние психологии на результаты торговли. Для этого нужно сформулировать торговую стратегию и реализовать ее в виде программы на языке MQL...
 
Nikolai Semko:

No, his algorithm is correct, just slow. There was a small mistake.
corrected and simplified:

You have a slow one.

 
Nikolai Semko:

No, it has the right algorithm, it's just slow. There was a small mistake.
I fixed it and simplified it:

I'll let you in on a terrible secret. Array Resize eats up a lot of resources.

 
Whatever.
 
Алексей Тарабанов:

I'll let you in on a terrible secret. Array Resize eats up a lot of resources.

if it were in a loop, but it's only executed once.

Drinking again?