Rezolvarea mea pentru problema descrisa mai sus:
#include <iostream>
using namespace std;
int main() {
int a,b,c,n,S,P,v[11],OK=0,i=3;
cin>>a>>b>>c>>n;
S = (-1)*b;
P = c;
switch(n) {
case 1: cout<<S; OK=1; break;
case 2: cout<<S*S - 2*P; OK=1; break;
}
if(!OK) {
v[1] = S;
v[2] = S*S - 2*P;
while(n!=2) {
v[i] = S*v[i-1] - P*v[i-2];
i++;
n--;
}
cout<<v[i-1];
}
return 0;
}