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