Класс может инициализировать массив, перетасовать его и распечатать:
Код: Выделить всё
#include
#include
#include
using namespace std;
class Array
{
public:
int array[8];
void init() {
array[0] = 1;
array[1] = 2;
array[2] = 3;
array[3] = 4;
array[4] = 5;
array[5] = 6; array[6] = 7;
array[7] = 8;
}
void shuffle()
{
random_device rd;
mt19937 g(rd());
std::shuffle(
&array[0],
&array[8],
g
);
}
void show()
{
for (int i = 8 - 1; i >= 0; i--)
cout
Подробнее здесь: [url]https://stackoverflow.com/questions/79821627/how-to-bubble-sort-an-array-stored-inside-a-class[/url]
Мобильная версия