#include<stdio.h>
#include<time.h>
#include<stdlib.h>
int paixu(int ,int);//洗牌声明
int main(){
  int a[4][13],d,i,j,m,num=0,t=0,b[52]={0};
  srand(time(NULL));
  for(i=0;i<4;i++){
      for(j=0;j<13;j++){
            a[i][j]=j+1;
      }  
  }
  for(;num<=52;){
      d=rand()%52;
      for(m=0;m<num;m++){
            if(d==b[m]){
                break;
            }
      }
      if(m==num){
            b[num]=d;
            switch(d/13){
                case 0:printf("红桃");break;
                case 1:printf("方块");break;
                case 2:printf("草花");break;
                case 3:printf("黑桃");break;
            }
            num++;
        b[t++]=a[d/13][d%13];
            printf("%2d%c",a[d/13][d%13],num%13==0 && num!=0?'\n':' '); 

      }

    paixu(0,13);paixu(13,26);paixu(26,39);paixu(39,52);
        }
       }return 0;
 } 


    int paixu(int m,int n)  //洗牌函数
    { for(i=m;i<n;i++)
        for(j=n-1;j>i;j++)
        if(b[j-1]>b[j])
        {
        t=b[j];b[j]=b[j-1];b[j-1]=t;
        x=0;
        for(x<13) printf("%2d",b[x++]); return 0;
        }
      }

Edited 3 Years Ago by mike_2000_17: Fixed formatting

1. Learn to use code tags. The code you posted is almost impossible to read without them.

2. What is the problem with your program? What does it not do that you want it to do? Are there any compiler errors? If yes, then what are thy?

#include<stdio.h>
#include<time.h>
#include<stdlib.h>
int paixu(int ,int);//洗牌声明
int main(){
int a[4][13],d,i,j,m,num=0,t=0,b[52]={0};
srand(time(NULL));
for(i=0;i<4;i++){
for(j=0;j<13;j++){
a[i][j]=j+1;
} 
}
for(;num<=52{
d=rand()%52;
for(m=0;m<num;m++){
if(d==b[m]){
break;
}
}
if(m==num){
b[num]=d;
switch(d/13){
case 0:printf("红桃");break;
case 1:printf("方块");break;
case 2:printf("草花");break;
case 3:printf("黑桃");break;
}
num++;
b[t++]=a[d/13][d%13];
printf("%2d%c",a[d/13][d%13],num%13==0 && num!=0?'\n':' '); 

}

paixu(0,13);paixu(13,26);paixu(26,39);paixu(39,52);
}
}return 0;
} 


int paixu(int m,int n) //洗牌函数
{ for(i=m;i<n;i++)
for(j=n-1;j>i;j++)
if(b[j-1]>b[j])
{
t=b[j];b[j]=b[j-1];b[j-1]=t;
x=0;
for(x<13) printf("%2d",b[x++]); return 0;
}
}

Well, you used code tags, but the formatting is still horrible. I you can't bothe to indent your program properly then I won't bother to read it.

Edited 6 Years Ago by Ancient Dragon: n/a

First,thank you any way !
I am very sorry,because it's my first time to come this community .
but,you teach me form a good coding habit!thanks for your enthusiasm .

There is a style that I like to use. Note that { and } braces are ligned up on the same position and you normally do not put more than one statement on the same line -- there are some exceptions as you will see in the switch statement.

This kind of coding style makes it very easy to find mismatches { and } characters and other coding problems. I found at least two when I was reformatting your code.

int main()
{
    int a[4][13],d,i,j,m,num=0,t=0,b[52]={0};
    srand(time(NULL));
    for(i=0;i<4;i++)
    {
        for(j=0;j<13;j++)
        {
            a[i][j]=j+1;
        } 
    }
    for(;num<=52;)
    {
        d=rand()%52;
        for(m=0;m<num;m++)
        {
            if(d==b[m])
            {
                break;
            }
        }
        if(m==num)
        {
            b[num]=d;
            switch(d/13)
            {
                case 0:printf("红桃");break;
                case 1:printf("方块");break;
                case 2:printf("草花");break;
                case 3:printf("黑桃");break;
            }
            num++;
            b[t++]=a[d/13][d%13];
            printf("%2d%c",a[d/13][d%13],num%13==0 && num!=0?'\n':' '); 

        }

        paixu(0,13);
        paixu(13,26);
        paixu(26,39);
        paixu(39,52);
    }
    return 0;
}
This article has been dead for over six months. Start a new discussion instead.