我写了一个计算函数,它也应该返回总和。但总和不能正常工作。 输出:
@Component({
selector: 'item-form',
template: `<form #itemForm="ngForm" (ngSubmit)="onSubmit(itemForm)">
<input type="text [(ngModel)]="item.title">
</form>`
})
export class ItemFormComponent implements OnInit {
@Input() item: Item;
private mode: String;
private service: ItemService;
constructor(service: ItemService, routeParams: RouteParams) {
this.service = service;
this.routeParams = routeParams;
if(this.routeParams.get('id')) {
this.mode = "edit";
}
else {
this.mode = "create";
}
}
onSubmit($form) {
console.info("Mode", this.mode);
if ($form.form.valid) {
}
}
ngOnInit() {
console.log(this.item);
}
ngOnChanges(changes: {[propName: string]: SimpleChange}) {
if(changes['item'].currentValue) {
console.log('ngOnChanges - changes = ' + changes['item'].currentValue);
}
}
总和应为20
代码:
public class GroupBox extends Pane {
public void configureGroupBox(String title) {
//Perform needed set up here.....
}
}
非常感谢任何帮助
答案 0 :(得分:1)
要做的两件事 -
1。将sum
初始化为1
-
int sum=1; //as you don't include 0 and 1 in loop
2。更改sum+=k;
声明的位置 -
printf("%d ",k);
sum+=k;
因为现在你的代码 -
k = i+j;
sum+=k;
在将{p> k
添加到sum
之前, flock()
正在被更改(不正确),导致回答错误。