My vector = {1, 2, 3, 4, 5}; // Vectordagi elementlarni tasodifiy tartibda joylashtirish


Download 142.17 Kb.
Sana18.06.2023
Hajmi142.17 Kb.
#1580168
Bog'liq
Dashturlash amaliy 16


1.masala
#include
#include
#include

int main() {


std::vector my_vector = {1, 2, 3, 4, 5};

// Vectordagi elementlarni tasodifiy tartibda joylashtirish


std::random_shuffle(my_vector.begin(), my_vector.end());

// Shuffle funksiyasi natijasini ekranga chiqarish


for (int i = 0; i < my_vector.size(); i++) {
std::cout << my_vector[i] << " ";
}
std::cout << std::endl;

return 0;


}

2.masala
#include
#include
#include

int main() {


std::deque my_deque = {1, 2, 3, 4, 5};

// Dequedagi elementlarni tasodifiy tartibda joylashtirish


std::random_shuffle(my_deque.begin(), my_deque.end());

// Shuffle funksiyasi natijasini ekranga chiqarish


for (int i = 0; i < my_deque.size(); i++) {
std::cout << my_deque[i] << " ";
}
std::cout << std::endl;

return 0;


}

3.masala
#include


#include
#include

int main() {


std::deque my_deque = {1, 2, 3, 4, 5};

// Dequedagi elementlarni tasodifiy tartibda joylashtirish


std::random_shuffle(my_deque.begin(), my_deque.end());

// Shuffle funksiyasi natijasini ekranga chiqarish


std::deque::iterator it;
for (it = my_deque.begin(); it != my_deque.end(); ++it) {
std::cout << *it << " ";
}
std::cout << std::endl;

return 0;


}

Download 142.17 Kb.

Do'stlaringiz bilan baham:




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©fayllar.org 2024
ma'muriyatiga murojaat qiling