sry ignore the last comment for i wanted to say - your algo will work only when the numbers given are consecutive.
-- Amol Sharma Final Year Student Computer Science and Engineering MNNIT Allahabad <http://gplus.to/amolsharma99> <http://twitter.com/amolsharma99><http://in.linkedin.com/pub/amol-sharma/21/79b/507><http://www.simplyamol.blogspot.com/><http://facebook.com/amolsharma99> On Fri, Jun 15, 2012 at 8:06 PM, Amol Sharma <amolsharm...@gmail.com> wrote: > @enchantress : > your algo will work only when the number given are positive. > -- > > > Amol Sharma > Final Year Student > Computer Science and Engineering > MNNIT Allahabad > <http://gplus.to/amolsharma99> > <http://twitter.com/amolsharma99><http://in.linkedin.com/pub/amol-sharma/21/79b/507><http://www.simplyamol.blogspot.com/> > > > > > > > On Fri, Jun 15, 2012 at 7:01 PM, shiv narayan > <narayan.shiv...@gmail.com>wrote: > >> this is the running code to find no of triangles using brute force >> technique >> logic: in a triangle having sides a,b,c; then a+b>c(if c is greatest side) >> correct me if i am wrong. >> >> #include<iostream> >> #include<conio.h> >> using namespace std; >> int max(int a,int b,int c) >> { >> return ((a>b?a:b)>c?(a>b?a:b):c); >> } >> int main() >> { >> int n,a[120],t,p,q; >> cin>>t; >> while(t--) >> { >> cin>>n; >> for(int i=0;i<n;i++) >> cin>>a[i]; >> int i,j,no_of_triangles=0,sum=0,largest_edge; >> for(i=0;i<n-2;i++) >> { >> for(j=i+2;j<n;j++) >> { >> sum=a[i]+a[i+1]+a[j]; >> largest_edge=max(a[i],a[i+1],a[j]); >> if(sum-largest_edge>largest_edge) >> { >> no_of_triangles++; >> cout<<a[i]<<" "<<a[i+1]<<" "<<a[j]<<"\n";} >> >> } >> } >> cout<<no_of_triangles<<endl; >> } >> getch(); >> return 0; >> } >> >> >> On Wednesday, 13 June 2012 22:18:01 UTC+5:30, payel roy wrote: >> >>> >>> Let's say there are N sides are given. Length of them are like >>> 1,2,3,4,5,....N. >>> >>> How do you determine how many tri-angles can be made out of these N >>> sides? >>> >> -- >> You received this message because you are subscribed to the Google Groups >> "Algorithm Geeks" group. >> To view this discussion on the web visit >> https://groups.google.com/d/msg/algogeeks/-/WizMjfsoizsJ. >> >> To post to this group, send email to algogeeks@googlegroups.com. >> To unsubscribe from this group, send email to >> algogeeks+unsubscr...@googlegroups.com. >> For more options, visit this group at >> http://groups.google.com/group/algogeeks?hl=en. >> > > -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.