Varianta 41 / Subiectul 3 / Problema 3 |
#include<iostream.h> void main() {int a[100],i,j,n,p; cin>>n; for(i=1;i<=n;i++) cin>>a[i]; p=1; for(i=1;i<=n;i++) for(j=i+1; j<=n;j++) if(a[i]==a[j]) p=0; if(p==1) for(i=1;i<=n-1;i++) if(a[i+1]-a[i]==1 || a[i]-a[i+1]==1) p=0; if(p==1) cout<<" da "; else cout<<" nu"; } |