shuffler.c

来自「在Linux编程环境下实现Shuffle排序算法」· C语言 代码 · 共 48 行

C
48 行
字号
/**
*  @file    shuffler.c
*  @brief   This main function to test the  shuffler() function
*  @author  Zhao Dong   zhdo0104@163.com
*  @date    2008/6/24
*/

#include <stdio.h>
#include"myshuffler.h"
#define NUM_CARDS  54

void cards_input(int * pcards)
{
     int i;
     for(i=0;i<NUM_CARDS;i++)
     {
          pcards[i]=i+1;                 
     }     
}

void cards_output(int * pcards)
{
     int i=0,j=0;
     for(i=0;i<NUM_CARDS;i++)
     {
          printf("%02d\t",pcards[i]);
          j++;
          if(j==10)
          {
                 printf("\n");
                 j=0;         
          }                 
     }  
     printf("\n");   
}

int main()
{
     int cards[54];
     int *pcards=cards;
     
     cards_input(pcards);
     shuffler(pcards);
     cards_output(pcards);
     
     return 1;    
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?