Răspuns:
#include <iostream>
#include <fstream>
using namespace std;
ifstream f("numere.in");
ofstream g("ramas.out");
int main()
{
int n,i,a,b,c;
f >> n;
if (n==1) {
f>>a;
g<<a;
}
else {
if (n==2) {
f >> a >> b;
g << a << " " << b;
}
else {
f >> a >> b;
g << a;
for (i=3; i<=n; i++) {
f >> c;
if (a+c!=2*b) {
g << " " << b;
}
a=b; b=c;
}
g << " " << c;
}
}
return 0;
}
Explicație: