Stek eng kichik elementi topilsin va undan keyin 0 joylashtirilsin.
#include
#include
using namespace std;
int main()
{
queue myq;
queue myq1;
int n,min,x; cin>>n;
for(int i=1; i<=n; i++)
{
cin>>x;
myq.push(x);
myq1.push(x);
}
min=myq.front();
for(int i=1; i<=n; i++)
{
if(min>myq.front())
min=myq.front();
myq.pop();
}
while (!myq1.empty())
{
if (myq1.front() == min)
cout << myq1.front() << " 0 ";
else cout << myq1.front() << " ";
myq1.pop();
}
}
Do'stlaringiz bilan baham: |