【发布时间】:2026-01-30 14:15:02
【问题描述】:
if (vote1 == 1) {
result[0] = result[0] + 1;
i.println(pres1 + " " + result[0]);
}
我的 if 语句最多为 4 个(例如:else if (vote1==2...3...4))。每次我选择多个候选人时,结果都会出错,有时输出会改变。我希望每次我选择候选人 1 时,他的选票都会增加,而且当我选择其他候选人时,输出不会发生任何变化。
例如:
candidate 1 = 8 (and increment)
candidate 2 = 3 (and increment)
candidate 3 = 5 (and increment)
candidate 4 = 6 (and increment)
请有人帮助我的项目真的需要它
【问题讨论】:
-
听起来像一个家庭作业:/
标签: java javascript arrays increment voting-system