I think this is the solution what u need.... U can do in O(n) time...

> #include<iostream>
>> using namespace std;
>>
>> main()
>> {
>> int a[7] = { 0, 0, 0, 19, 380, -1, 2};
>> int prod, nprod;
>> bool x = false;
>>
>> for(int i=0;i<6;i++)
>> {
>> nprod = a[i] * a[i+1];
>> cout<<nprod<<endl;
>> if( x == false)
>> {
>> x = true;
>> prod = nprod;
>> }
>> else if( x== true && prod < nprod )
>> prod = nprod;
>> }
>>
>> cout<<"\nResult: "<<prod;
>> }
>>
>
>
-- 
Regards:
-----------------------
D Kranthi kumar
Computer Science & Engg.
1st Mtech, IIT Madras.

-- 
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.

Reply via email to