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