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