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 0s 5284KB
stdin
Standard input is empty
stdout
1:400-8
2:100-8
3:100-3
4:200-7
5:300-11
6:400-9
7:300-13
8:200-4
9:200-8
10:400-4
11:400-3
12:200-11
13:300-5
14:300-3
15:200-2
16:100-7
17:400-2
18:100-1
19:100-6
20:100-5
21:200-10
22:300-6
23:300-10
24:400-13
25:400-12
26:200-3
27:400-1
28:400-11
29:200-6
30:300-12
31:100-2
32:400-7
33:100-13
34:100-4
35:400-6
36:200-1
37:200-5
38:300-7
39:100-12
40:100-11
41:200-13
42:400-10
43:200-12
44:400-5
45:300-8
46:200-9
47:300-4
48:300-9
49:100-10
50:300-2
51:300-1
52:100-9