fork download
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <time.h>
  4. //dai4kai
  5. void shuffle(int [][13]);
  6. void print_trump(int [][13],int*,int*);
  7. int main(void) {
  8. int deck[4][13]={0};
  9. int trump_mark[4]={100,200,300,400};
  10. int trump_num[13]={1,2,3,4,5,6,7,8,9,10,11,12,13};
  11. shuffle(deck);
  12. print_trump(deck,trump_mark,trump_num);
  13. return 0;
  14. }
  15. void shuffle(int deck[][13]){
  16. int count=0;
  17. srand(time(NULL));
  18. while(count<52){
  19. int m=rand()%4;
  20. int n=rand()%13;
  21. if(deck[m][n]==0){
  22. deck[m][n]=count+1;
  23. count++;
  24. }
  25. }
  26. }
  27. void print_trump(int deck[][13],int trump_mark[4],int trump_num[13]){
  28. int i,m,n;
  29. for(i=0;i<52;i++){
  30. printf("%2d:",i+1);
  31. for(m=0;m<4;m++){
  32. for(n=0;n<13;n++){
  33. if(deck[m][n]==i+1){
  34. if(trump_mark[m]==100) printf("100-%d\n",trump_num[n]);
  35. else if(trump_mark[m]==200) printf("200-%d\n",trump_num[n]);
  36. else if(trump_mark[m]==300) printf("300-%d\n",trump_num[n]);
  37. else if(trump_mark[m]==400) printf("400-%d\n",trump_num[n]);
  38. }
  39. }
  40. }
  41. }
  42. }
Success #stdin #stdout 0s 5276KB
stdin
Standard input is empty
stdout
 1:400-12
 2:100-9
 3:300-2
 4:400-9
 5:100-11
 6:400-4
 7:100-3
 8:100-10
 9:200-2
10:200-13
11:400-13
12:400-7
13:200-1
14:200-6
15:200-9
16:400-8
17:200-11
18:400-5
19:100-7
20:100-4
21:400-3
22:300-11
23:300-13
24:300-8
25:200-5
26:200-4
27:300-4
28:100-12
29:100-1
30:300-3
31:200-7
32:300-6
33:200-8
34:400-10
35:400-11
36:100-5
37:300-9
38:400-1
39:400-2
40:300-10
41:200-12
42:200-10
43:300-5
44:100-8
45:100-2
46:300-12
47:200-3
48:300-1
49:300-7
50:100-6
51:400-6
52:100-13