Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int NrTriplete(int a[],int n,int S)
- {
- sort(a,a+n);
- int nrt=0;
- for(int i=0;i<n-2;++i)
- {
- int j=i+1,N=n-1;
- while(j<N)
- {
- if(a[i]+a[j]+a[N]>=S)
- --N;
- else
- nrt+=(N-j),++j;
- }
- }
- return nrt;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement