我正在尝试添加两个多项式,但每当我的代码执行时它返回零。我希望有人可以向我指出我正在做什么以及如何解决它。感谢
{
"Comment": "A state machine that publishes to SNS after a deployment completes.",
"StartAt": "StartDeployment",
"States": {
"StartDeployment": {
"Type": "Task",
"Resource": "arn:aws:lambda:us-east-1:012345678912:function:KickOffDeployment",
"ResultPath": "$.guid",
"Next": "CheckIfDeploymentComplete"
},
"CheckIfDeploymentComplete": {
"Type": "Task",
"Resource": "arn:aws:lambda:us-east-1:012345678912:function:CheckIfDeploymentComplete",
"Next": "TriggerWebAppRefresh",
"InputPath": "$.guid",
"ResultPath": "$.status",
"Retry": [ {
"ErrorEquals": [ "INPROGRESS" ],
"IntervalSeconds": 5,
"MaxAttempts": 240,
"BackoffRate": 1.0
} ],
"Catch": [ {
"ErrorEquals": ["FAILED"],
"Next": "DeploymentFailed"
}]
},
"DeploymentFailed": {
"Type": "Fail",
"Cause": "Deployment failed",
"Error": "Deployment FAILED"
},
"TriggerWebAppRefresh": {
"Type": "Task",
"Resource": "arn:aws:lambda:us-east-1:012345678912:function:SendSNSToWebapp",
"InputPath": "$.guid",
"End": true
}
}
}
答案 0 :(得分:0)
您正在尝试将链接列表poly1和poly2添加到一起,结果将存储在新的链接列表中。
但是,您没有正确构建生成的链接列表。在为每个不同程度创建新节点时,您无法正确创建新节点,并将它们链接在一起。 代码:
polyAdd = new Node (coeff, degree, null);
删除对前一个polyAdd的任何引用。
保持链表顺利的正确方法是:
polyAdd.next = new Node(coeff, degree, null);