我有这个代码,我打算创建一套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]);
}
}发布于 2017-11-22 12:54:26
posNaipe = i % NCARTAS / 13;就能做到。这也是你了解运算符优先性和结合性的试金石。
https://stackoverflow.com/questions/47435247
复制相似问题