View Single Post
  #11 (permalink)  
Old 07-04-2009, 04:54 PM
angryboy's Avatar
angryboy angryboy is offline
Senior Member
 
Join Date: Jan 2009
Location: Javaland
Posts: 742
Rep Power: 2
angryboy is on a distinguished road
Default
for calculation, you are using two loops and one statment. You can actually shorten that to only one loop by checking for negative numbers (which mean array out of bounds here). for example:
Code:
if(vs1-i<0) 
  a = 0;
else 
  a = vArray1[vs1-i];

//and the same for b 
// then
int sum = a + b + c;
...
And I would suggest breaking it down to small manageable methods:
getInput()
add()
write()

edit:
also in the input, how do you plan to handle negative values?
__________________
USE CODE TAGS--> [CODE]...[/CODE]
Get NotePad++ (free)

Last edited by angryboy; 07-04-2009 at 05:06 PM.
Reply With Quote