1 int f(int*a,int*b,int n) 2 { 3 if(!a||!b||n<3) return -1; 4 int*temp=new int[n](); 5 int max=a[0],count=0; 6 for (int i=1;i<n-1;i++) 7 if(a[i]>max) 8 { 9 temp[i]++; 10 max=a[i]; 11 } 12 int min=a[n-1]; 13 for (int i=n-2;i>0;i--) 14 if(a[i]<min) 15 { 16 temp[i]++; 17 min=a[i]; 18 } 19 for (int i=1;i<n-1;i++) 20 if(temp[i]==2) b[count++]=a[i]; 21 delete[]temp; 22 return count; 23 }