Dastur kodi #include


Download 31.7 Kb.
Sana09.06.2023
Hajmi31.7 Kb.
#1474845
Bog'liq
4-amalish Saidmurod


4-AMALIYOT ISHI
MAVZU:STACK,QUEUE,DEQUEUE(STEK,NAVBAT,DEK)

VARIANT-22
N ta elementdan tashkil topgan stack berilgan.stackni eng kichik elementini toping va uni 0 bilan almashtiring.

DASTUR KODI
#include
#include
using namespace std;
int main(){
stack st;
stack ans;
int n, a;
cin >> n;
cin >> a;
int mi = a;
st.push(a);
for (int i = 1; i < n; i++)
{
cin >> a;
if(mi > a)
mi = a;
st.push(a);
}
while (!st.empty())
{
a = st.top();
if (a == mi)
ans.push(0);
else
ans.push(a);
st.pop();
}
while (!ans.empty())
{
cout << ans.top() << " ";
ans.pop();
}
}
NATIJA:

Download 31.7 Kb.

Do'stlaringiz bilan baham:




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