#include <iostream>
using namespace std;
int main()
{
const int N = 5;
int tablica[N] = {3, 5, 2, 1, 4};
for (int i = 0; i < N - 1; i++)
int m = i;
for (int j = i + 1; j < N; j++)
if (tablica[j] > tablica[m])
m = j;
}
swap(tablica[i], tablica[m]);
for (int i = 0; i < N; i++)
cout << tablica[i] << " ";
return 0;
" Life is not a problem to be solved but a reality to be experienced! "
© Copyright 2013 - 2025 KUDO.TIPS - All rights reserved.
#include <iostream>
using namespace std;
int main()
{
const int N = 5;
int tablica[N] = {3, 5, 2, 1, 4};
for (int i = 0; i < N - 1; i++)
{
int m = i;
for (int j = i + 1; j < N; j++)
{
if (tablica[j] > tablica[m])
m = j;
}
swap(tablica[i], tablica[m]);
}
for (int i = 0; i < N; i++)
cout << tablica[i] << " ";
return 0;
}