#include <iostream>
using namespace std;
int main()
{
int mas[20] = {};
for (int jjj = 0; jjj < 20; jjj++)
cin >> mas[jjj];
if (cin.fail())
cin.clear();
cin.ignore(32000, '\n');
break;
};
cout<<"\nДо : ";
for(int jjj:mas)cout<<jjj<<" ";
for (int kkk{0} ,jjj{0}; jjj <20; jjj++)
if (mas[jjj] == 0)
swap(mas[kkk++], mas[jjj]);
cout<<"\nПосле : ";
}
Copyright © 2024 SCHOLAR.TIPS - All rights reserved.
Answers & Comments
#include <iostream>
using namespace std;
int main()
{
int mas[20] = {};
for (int jjj = 0; jjj < 20; jjj++)
{
cin >> mas[jjj];
if (cin.fail())
{
cin.clear();
cin.ignore(32000, '\n');
break;
};
};
cout<<"\nДо : ";
for(int jjj:mas)cout<<jjj<<" ";
for (int kkk{0} ,jjj{0}; jjj <20; jjj++)
if (mas[jjj] == 0)
swap(mas[kkk++], mas[jjj]);
cout<<"\nПосле : ";
for(int jjj:mas)cout<<jjj<<" ";
}