|
Ergasheva Sevara 2-topshiriq Variant 13
|
Sana | 16.05.2024 | Hajmi | 62,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
#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;
}
|
| |