Amaliyot ishi bajardi: Hoshimjonov Ikromjon


Download 28.96 Kb.
Sana06.11.2023
Hajmi28.96 Kb.
#1750672
Bog'liq
Hoshimjonov ikromjon


AMALIYOT ISHI
BAJARDI: Hoshimjonov Ikromjon
Guruh: 314-22
Variant-5

5. N ta elementdan tashkil topgan stek berilgan. Stekning barcha barcha elelementlari yig’indisini toping.

#include
#include
using namespace std ;
int main() {
stack myStack;
int n;
int sum = 0;
cout << "Elementlar sonini kiriting: ";
cin >> n;
cout << "Stekning elementlarini kiriting: ";
for (int i = 0; i < n; i++) {
int num;
cin >> num;
myStack.push(num);
sum += num;
}
cout << "Stekning barcha elementlarining yig'indisi: " << sum << endl;
return 0;
}

Download 28.96 Kb.

Do'stlaringiz bilan baham:




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