117 lines
5.3 KiB
MQL5
117 lines
5.3 KiB
MQL5
//+------------------------------------------------------------------+
|
|
//| Test.mq5 |
|
|
//| Copyright 2019, MetaQuotes Software Corp. |
|
|
//| https://www.mql5.com |
|
|
//+------------------------------------------------------------------+
|
|
#property copyright "Copyright 2019, MetaQuotes Software Corp."
|
|
#property link "https://www.mql5.com"
|
|
#property version "1.00"
|
|
//---
|
|
struct Person
|
|
{
|
|
int age;
|
|
int height;
|
|
};
|
|
//+------------------------------------------------------------------+
|
|
//| Script program start function |
|
|
//+------------------------------------------------------------------+
|
|
void OnStart()
|
|
{
|
|
//---
|
|
Person person[];
|
|
|
|
//---
|
|
for(int i=0; i<=9; i++)
|
|
{
|
|
//---
|
|
ArrayResize(person,ArraySize(person)+1);
|
|
|
|
//---
|
|
person[ArraySize(person)-1].age=i;
|
|
person[ArraySize(person)-1].height=i;
|
|
}
|
|
|
|
//---
|
|
for(int i=10; i>=5; i--)
|
|
{
|
|
//---
|
|
ArrayResize(person,ArraySize(person)+1);
|
|
|
|
//---
|
|
person[ArraySize(person)-1].age=i;
|
|
person[ArraySize(person)-1].height=i;
|
|
}
|
|
|
|
//---
|
|
for(int i=6; i<=15; i++)
|
|
{
|
|
//---
|
|
ArrayResize(person,ArraySize(person)+1);
|
|
|
|
//---
|
|
person[ArraySize(person)-1].age=i;
|
|
person[ArraySize(person)-1].height=i;
|
|
}
|
|
|
|
//---
|
|
for(int i=14; i>=10; i--)
|
|
{
|
|
//---
|
|
ArrayResize(person,ArraySize(person)+1);
|
|
|
|
//---
|
|
person[ArraySize(person)-1].age=i;
|
|
person[ArraySize(person)-1].height=i;
|
|
}
|
|
|
|
|
|
//---
|
|
ArrayPrint(person);
|
|
|
|
//---
|
|
Print("<<<------------------------------------------------------------------->>>");
|
|
|
|
//---
|
|
Person person_temp[];
|
|
|
|
//---
|
|
int person_temp_size=0;
|
|
|
|
//---
|
|
for(int i=0; i<ArraySize(person); i++)
|
|
{
|
|
//---
|
|
if(i==0)
|
|
continue;
|
|
|
|
if(person[i].age>person[i-1].age)
|
|
{
|
|
//---
|
|
if(person_temp_size==0)
|
|
{
|
|
//---
|
|
ArrayResize(person_temp,++person_temp_size);
|
|
|
|
//---
|
|
person_temp[person_temp_size-1]=person[i-1];
|
|
}
|
|
|
|
//---
|
|
ArrayResize(person_temp,++person_temp_size);
|
|
|
|
//---
|
|
person_temp[person_temp_size-1]=person[i];
|
|
}
|
|
else
|
|
{
|
|
//---
|
|
ArrayPrint(person_temp);
|
|
|
|
//---
|
|
ArrayFree(person_temp);
|
|
}
|
|
}
|
|
|
|
//---
|
|
}
|
|
//+------------------------------------------------------------------+
|