fork download
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <time.h>
  4. void sh(int [][13]);
  5. void print(int [][13],int*,int*);
  6. int main(void){
  7. int mark[4]={100,200,300,400};
  8. int num[13]={1,2,3,4,5,6,7,8,9,10,11.12,13};
  9. int deck[4][13]={0};
  10. srand(time(NULL));
  11. sh(deck);
  12. print(deck,mark,num);
  13.  
  14. }
  15.  
  16.  
  17. void sh(int de[][13]){
  18. int Anum,row,Amark;
  19. for(Anum=1;Anum<=52;Anum++){
  20. do{
  21. row=rand()%4;
  22. Amark=rand()%13;
  23. }while(de[row][Amark]!=0);
  24. de[row][Amark]=Anum;
  25. }
  26. }
  27.  
  28. void print(int A[][13],int *m,int *n ){
  29. int Bnum,Brow,Bmark;
  30. for(Bnum=1;Bnum<=52;Bnum++){
  31. for(Brow=0;Brow<4;Brow++){
  32. for(Bmark=0;Bmark<13;Bmark++){
  33. if(A[Brow][Bmark]==Bnum){
  34. printf("%5d:%d-%d\n",Bnum,m[Brow],n[Bnum]);
  35. }
  36. }
  37. }
  38. }
  39. }
  40.  
  41.  
  42.  
  43.  
  44.  
  45.  
  46.  
  47.  
Success #stdin #stdout 0s 5268KB
stdin
Standard input is empty
stdout
    1:100-2
    2:300-3
    3:400-4
    4:300-5
    5:300-6
    6:400-7
    7:100-8
    8:400-9
    9:200-10
   10:400-11
   11:300-13
   12:300-0
   13:200-32766
   14:100--766973296
   15:300-32766
   16:100-19
   17:400-7
   18:200-22
   19:100-20
   20:100-25
   21:400-1
   22:100-24
   23:300-28
   24:100-16
   25:100-48
   26:300-45
   27:400-14
   28:100-34
   29:300-13
   30:400-32
   31:200-49
   32:200-42
   33:200-43
   34:100-38
   35:200-35
   36:300-40
   37:200-9
   38:200-33
   39:400-31
   40:200-37
   41:400-18
   42:200-47
   43:200-12
   44:300-26
   45:100-46
   46:300-11
   47:300-29
   48:100-5
   49:200-44
   50:400-36
   51:400-23
   52:400-15