|
|
back to board1079 Легкий вопрос, ПОМОГИТЕЕЕ Posted by Mikael 21 Nov 2010 17:11 5 - оутпут 3 10 - оутпут 4 0 (return) Got to do only one thing find the maximum in this array If the array size is 5 then maximum = 3 and if 10 then 4 is max so, I solved the problem in the givven way and in given way the max of 5(sized array) isn't 3 here is the input and output cin>> 5 0 1 1 2 1 max = 2 _____________________________ cin >> 10 0 1 1 2 1 3 2 3 1 4 max = 4 _______________________________________ input>>6 0 1 1 2 1 3 max = 3 ______________________________________ please help the Solution of Problem is Actually thiS, In c++ But dOesn't work maybe you can notice something?? for(int i = 0; i < a; i++){ if(2*i < a){ arr[2*i] = arr[i]; } if(2*i+1 < a){ arr[2*i+1] = arr[i] + arr[i+1]; } } Re: 1079 Легкий вопрос, ПОМОГИТЕЕЕ Posted by Mikael 21 Nov 2010 19:13 OK already got it |
|
|