.Write a program in C++ to input an array of 10 numbers and check whether it is an unique array or not , using a recursive function
#include<iostream.h>
#include<conio.h> int unique(int a[ ],int j=1,int i=0) { if(i==10) return 0; else { if(j>=9) { j=i+1; return unique(a,i++,j); } if(a[i]==a[j]) return 1; else return unique(a,i++,j); } } void main() { clrscr(); int a[10],p=0; for(int i=0;i<10;i++) cin>>a[i]; p=unique(a); if(p==0) cout<<"”unique”"<<endl; else cout<<"”not unique”"<<endl; getch(); } |