Răspuns:
#include <iostream>
#include <fstream>
#include <cstring>
using namespace std;
ifstream f("nrasoc.in");
ofstream g("nrasoc.out");
int main()
{
int x, y, z, gata = 0;
f >> x >> y;
while (!gata && f >> z)
{
if (x >= z)
{
g << x << " ";
x = y; y = z;
}
else gata = 1;
}
if (gata)
{
g << z << " ";
while (f >> z) g << z << " ";
}
return 0;
}
Explicație: