æ¾ç»ä¹éå°è¿åæ ·çé¢ç®ï¼å½æ¶æ²¡è®¾è®¡å¥½ï¼ä»å¤©ç»äºå®æäºè¿ä¸ªå·¥ä½ã对ç¨åºæä»»ä½çé®è¯·å QQï¼770305791
æçç®æ³ä¸å
¶ä»çç®æ³ä¸ä¸æ ·ï¼å¦æä½ è½ç»ç»åæå°±å¯ä»¥åç°ï¼ä»£ç å¦ä¸ï¼
#include<stdio.h>
#include<time.h>
#include<stdlib.h>
void insert_sort(int b[52])
{
int n[52] = {0}, i, j;
for(i = 0; i < 52; i++)
{
for(j = 0; j <= b[i]; j ++)
{
if(n[j] == 1)
b[i] ++;
}
n[b[i]] = 1;
}
}
int main()
{
char s[4];
int d,i,j;
int b[52]={0};
srand(time(NULL));
for(i = 52; i > 0; i --) //è¿ç§æ¹å¼é¿å
äºä¸ç´äº§çéæºæ°
{
d = rand() % i;
b[52 - i] = d;
}
insert_sort(b); //è°ç¨äºæåºå½æ°
printf("\n");
for(i = 0; i < 52; i ++)
printf("%4d", b[i]); //b[i]éé¢åå¨çæ¯éæºçç
printf("\n");
//åªéè¦ç¨ä»£ç åç»å个人æ¾ç¤ºåºæ¥å°±OK
/*ç»ä¸ªç¤ºä¾
printf("player1: ");
for(i = 0; i < 52; i += 4)
{
if(b[i] / 13 == 0)
if(b[i] % 13 == 0)
sprintf(s, "hA");
else if(b[i] % 13 == 10)
sprintf(s, "hJ");
else if(b[i] % 13 == 11)
sprintf(s, "hQ");
else if(b[i] % 13 == 12)
sprintf(s, "hK");
else
sprintf(s, "h%d", b[i] % 13 + 1);
else if(b[i] / 13 == 1)
if(b[i] % 13 == 0)
sprintf(s, "sA");
else if(b[i] % 13 == 10)
sprintf(s, "sJ");
else if(b[i] % 13 == 11)
sprintf(s, "sQ");
else if(b[i] % 13 == 12)
sprintf(s, "sK");
else
sprintf(s, "s%d", b[i] % 13 + 1);
else if(b[i] / 13 == 2)
if(b[i] % 13 == 0)
sprintf(s, "dA");
else if(b[i] % 13 == 10)
sprintf(s, "dJ");
else if(b[i] % 13 == 11)
sprintf(s, "dQ");
else if(b[i] % 13 == 12)
sprintf(s, "dK");
else
sprintf(s, "d%d", b[i] % 13 + 1);
else if(b[i] / 13 == 3)
if(b[i] % 13 == 0)
sprintf(s, "cA");
else if(b[i] % 13 == 10)
sprintf(s, "cJ");
else if(b[i] % 13 == 11)
sprintf(s, "cQ");
else if(b[i] % 13 == 12)
sprintf(s, "cK");
else
sprintf(s, "c%d", b[i] % 13 + 1);
printf("%-4s", s);
}
*/
}
温馨提示:答案为网友推荐,仅供参考