我有这个代码,我打算创建一组4个套牌,问题是在套装中,在卡片51之后,分割的结果给出4并且套装的数组不返回初始位置,我该如何解决这种情况?
谢谢
#include <stdio.h>
#define NCARTAS 52
int main()
{
const char *numero[]= {"A","2","3","4","5","6","7","8","9","10","V","D","R"};
const char *naipes[]= {"P","O","C","E"};
char baralho[208];
int posNumero,posNaipe;
for(int i=0; i<208; i++)
{
baralho[i]=i;
posNumero=i%13;
posNaipe=i/13;
printf("%s%s \n", numero[posNumero],naipes[posNaipe]);
}
}
答案 0 :(得分:3)
posNaipe = i % NCARTAS / 13;
会这样做。这也是您了解运算符优先级和关联性的试金石。