我是编程世界的新手(非常高兴能成为其中的一员)。我相信我想要做的事情非常简单,但是我找不到很多关于不适用于SA-MP
的PAWN文件编程。我有一个'.p'文件,它应该检查数组的三明治数字与限定符号码数组。据我所知,我可以通过我的代码传递一个数组来检查它是否匹配。这些是我的阵列:
+ new spec_bacon_plus[] = { 30500, 30100, 30400, 33100, 30300 }
+ new correct_spec_bacon_qual[] = { 9094400, 9013400, 9013400, 9093400, 9094400 }
+ new all_bacon_plus[] = {
9093400, /* add(1) bacon */
9013400, /* add(2) bacon */
9094400, /* add(3) bacon */
9095400, /* add(4) bacon */
9096400, /* add(6) bacon */
9097400, /* add(8) bacon */
}
我的代码如下。我试图检查我的spec_bacon_plus是否发生,如果他们这样做,我的all_bacon_plus会发生吗?如果spec_bacon_plus中的数字与correct_spec_bacon_qual中的数字不对齐,则显示错误。我相信,由于他们的立场,他们彼此“联系在一起”。 (例如,30500是9094400,30100是9013400,30400是9013400等)。
for(k = 0; k < sizeof spec_bacon_plus; k++) {
if(p_plu == spec_bacon_plus[k]) { /* the sandwich we rung up is the kth bacon sandwich */
for(m = 0; m < sizeof all_bacon_plus; m++) { /* check if the qualifer was any of the bacons */
if (p_qualifier == correct_spec_bacon_qual[m] && k != m ) /* && not in the slot that we expect */
ok = 0; /*not cool*/
pos_popup_dialog("THIS BACON IS NOT OK!");
ok = 1;
check_spec_bacon_plu = p_plu;
check_spec_bacon_qual = p_qualifier;
check_spec_bacon_qual_should_be = correct_spec_bacon_qual[k];
有什么想法吗?
答案 0 :(得分:0)
我明白了......
for(k = 0; k < sizeof spec_bacon_plus; k++) {
if(p_plu == spec_bacon_plus[k]) { /* the sandwich we rung up is the kth bacon sandwich */
for(m = 0; m < sizeof all_bacon_plus; m++) { /* check if the qualifer was any of the bacons */
if (p_qualifier == all_bacon_plus[m]) /* && not in the slot that we expect */
for(l = 0; l < sizeof correct_spec_bacon_qual; l++) {
if (p_qualifier == correct_spec_bacon_qual[k])
pos_popup_dialog("THIS BACON IS OK!");
else pos_popup_dialog("THIS BACON NOT IS OK!");