Răspuns:
#include<iostream>
#include<fstream>
using namespace std;
int main()
{
fstream f("date.txt",ios::in);
int x,y,aux,a;
f>>x>>y>>a;
if(y>x)
{
aux=y;
y=x;
x=aux;
}
while(!f.eof()&&a<y)
{
cout<<a<<" ";
f>>a;
}
cout<<y<<" ";
while(!f.eof()&&a<x)
{
cout<<a<<" ";
f>>a;
}
cout<<x<<" ";
while(!f.eof())
{
cout<<a<<" ";
f>>a;
}
}
Explicație: