大家好,我是java的菜鸟,所以不确定它的怪癖,但这在C#中有效吗?使用这段代码获得相同的结果时遇到了一些麻烦:
for (int i = 0; i < 50; i++){
ar1 = array[i][0];
ar2 = array[i][1];
ar3 = array[i][2];
ar4 = array[i][3];
ar5 = array[i][4];
ar6 = array[i][5];
if (ar1 == rs1 || ar1 == rs2 || ar1 == rs3 || ar1 == rs4 || ar1 == rs5 || ar1 == rs6)
M++;
if (ar2 == rs1 || ar2 == rs2 || ar2 == rs3 || ar2 == rs4 || ar2 == rs5 || ar2 == rs6)
M++;
if (ar3 == rs1 || ar3 == rs2 || ar3 == rs3 || ar3 == rs4 || ar3 == rs5 || ar3 == rs6)
M++;
if (ar4 == rs1 || ar4 == rs2 || ar4 == rs3 || ar4 == rs4 || ar4 == rs5 || ar4 == rs6)
M++;
if (ar5 == rs1 || ar5 == rs2 || ar5 == rs3 || ar5 == rs4 || ar5 == rs5 || ar5 == rs6)
M++;
if (ar6 == rs1 || ar6 == rs2 || ar6 == rs3 || ar6 == rs4 || ar6 == rs5 || ar6 == rs6)
M++;
if (M == 3)
w3++;
if (M == 4)
w4++;
if (M == 5)
w5++;
if (M == 6)
w6++;
}
lbl3.setText(String.valueOf(w3));
lbl4.setText(String.valueOf(w4));
lbl5.setText(String.valueOf(w5));
lbl6.setText(String.valueOf(w6));
在 for 循环中:
将 ar(N) 设置为数组的一部分
检查 rs(N) 然后如果为真则增加 M
检查 M 以查看其 3、4、5、6 是否为真,然后增加 w(N)
最后在标签上显示 w(N) 的所有总数,例如 lbl3、10 lbl4、22 lbl5、12 lbl6、6
但我得到的只是一个标签给出的总数为 1 或所有的标签为 1!尝试用 {} 括起来并使用(否则如果),数组已满,所以我很难过!!!