Ergasheva Sevara 2-topshiriq Variant 13




Download 62,98 Kb.
Sana16.05.2024
Hajmi62,98 Kb.
#237921
Bog'liq
Sevara dasturlash 2-amaliy


MUHAMMAD AL-XORAZMIY NOMIDAGI TOSHKENT AXBOROT TEXNOLOGIYALARI UNIVERSITETI

Ergasheva Sevara
2-topshiriq
Variant 13

Toshkent 2024
1-Vazifa

13

Ro‘yxatning nusxasini qurish, lekin teskari tartibda.

#include
#include
#include

using namespace std;


int main() {


vector originalList = { 5, 3, 1, 4, 2 };

vector reversedList(originalList);


reverse(reversedList.begin(), reversedList.end());


cout << "Teskari ro'yxat:" << endl;


for (int num : reversedList) {
cout << num << " ";
}
cout << endl;

return 0;


}



13

Stek elementlari teskari tartibda joylashtirib chiqilsin.

#include
#include
#include
#include

using namespace std;


int main() {


stack originalStack;
originalStack.push(5);
originalStack.push(3);
originalStack.push(1);
originalStack.push(4);
originalStack.push(2);

vector tempList;


while (!originalStack.empty()) {
tempList.push_back(originalStack.top());
originalStack.pop();
}

stack reversedStack;


for (int num : tempList) {
reversedStack.push(num);
}

cout << "Teskari stek:" << endl;


while (!reversedStack.empty()) {
cout << reversedStack.top() << " ";
originalStack.push(reversedStack.top());
reversedStack.pop();
}
cout << endl;

cout << "Original stek:" << endl;


while (!originalStack.empty()) {
cout << originalStack.top() << " ";
originalStack.pop();
}

return 0;


}

Download 62,98 Kb.




Download 62,98 Kb.

Bosh sahifa
Aloqalar

    Bosh sahifa



Ergasheva Sevara 2-topshiriq Variant 13

Download 62,98 Kb.