请教高手 --- JAVA

这都不是事儿

封禁 用户
注册
2014-04-01
消息
2,553
荣誉分数
371
声望点数
93
question3.JPG
 
。。。在java里啥意思?
 
我猜丑鸭一定是个胖子:
一个胖子打的句号都要比他人的胖o
 
static int recursive_sum(Vector pymts)
{
// eturn condition
if (pymts.size() == 0) return 0;

// recursive steps, vector has at least size of 1, of payment type (assume all objects are class Payment)
return pymts.remove(0).sum + recursive_sum(pymts);
}
 
Above is destructive recursive and a lot of school doesn't like it cause at the end. The original vector will become empty.

Just make a shadow copy before recurse
 
青鸟蓝翔双学历的出现了,再拿个新东方就圆满了:D
 
static int recursive_sum(Vector pymts)
{
// eturn condition
if (pymts.size() == 0) return 0;

// recursive steps, vector has at least size of 1, of payment type (assume all objects are class Payment)
return pymts.remove(0).sum + recursive_sum(pymts);
}


:zhichi::zhichi::zhichi:
 
后退
顶部