Daca vrei si varianta fara subprogram, spune:
#include <iostream>
using namespace std;int prime(int a,int b){ int r; while(a!=b) if(a>b) a=a-b; else b=b-a; if(a==1) return 1; else return 0;}int main(){ int i,n,ok=0,poz,v[100]; cin>>n; for(i=1;i<=n;i++) cin>>v[i]; for(i=1;i<n&&ok==0;i++) if(prime(v[i],v[i+1])) { ok=1; poz=i; } if(ok) for(i=1;i<=n;i++) cout<<v[i]<<" "; else cout<<"Nu exista";
return 0;
}