Website Summary Files Commits Branches @commit @diff @stats
path: root / pract_SI / Pract. 05 / Solutions / task5.cpp
blob: 06769873212a4168992809c1de24cfa93150f162 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
void swap(int &first,int &second)
{
    int temp = first;
    first = second;
    second = temp;
}

void specificOrderArray(int *arr,int size)
{
	bool isBigger = true;

    for (int i=0; i < size - 1; i++)
    {
        if (isBigger)
            if (arr[i] < arr[i+1])
                swap(arr[i], arr[i+1]);
		else
            if (arr[i] > arr[i+1])
                swap(arr[i], arr[i+1]);
			
        isBigger = !isBigger;
    }
}