欧美大屁股bbbbxxxx,狼人大香伊蕉国产www亚洲,男ji大巴进入女人的视频小说,男人把ji大巴放进女人免费视频,免费情侣作爱视频

歡迎來(lái)到入門(mén)教程網(wǎng)!

C語(yǔ)言

當(dāng)前位置:主頁(yè) > 軟件編程 > C語(yǔ)言 >

C語(yǔ)言中數(shù)據(jù)結(jié)構(gòu)之鏈?zhǔn)交鶖?shù)排序

來(lái)源:本站原創(chuàng)|時(shí)間:2020-01-10|欄目:C語(yǔ)言|點(diǎn)擊: 次

C語(yǔ)言中數(shù)據(jù)結(jié)構(gòu)之鏈?zhǔn)交鶖?shù)排序

實(shí)現(xiàn)效果圖:

實(shí)例代碼:

#include<stdio.h>
#include<string.h>
#include<stdlib.h>

#define TRUE 1
#define FALSE 0
#define OK 1
#define ERROR 0
#define INFEASIBLE -1

typedef int Status;
typedef int ElemType;

#define MAX_NUM_OF_KEY 8 //關(guān)鍵字項(xiàng)數(shù)最大值
#define RADIX 10 //關(guān)鍵字基數(shù),此時(shí)是十進(jìn)制整數(shù)的基數(shù)
#define MAX_SPACE 100 //書(shū)上為10000
#define ord(ch) ((ch)-'0')
#define succ(x) ((x)+1)
typedef char KeyType;
typedef struct
{
  KeyType keys[MAX_NUM_OF_KEY]; //關(guān)鍵字
  int next;
}SLCell;  //靜態(tài)鏈表的結(jié)點(diǎn)類型

typedef struct
{
  SLCell r[MAX_SPACE]; //靜態(tài)鏈表的可利用空間,r[0]為頭結(jié)點(diǎn)
  int keynum; //記錄當(dāng)前關(guān)鍵字個(gè)數(shù)
  int recnum; //靜態(tài)鏈表的當(dāng)前長(zhǎng)度
}SLList;  //靜態(tài)鏈表類型
typedef int ArrType[RADIX]; //指針數(shù)組類型

/*******************************聲明部分****************************************/



/*******************************函數(shù)部分****************************************/
void Distribute(SLCell r[],int i,ArrType f,ArrType e)
{
  int j,p;

  for(j = 0;j<RADIX;++j){
    f[j] = 0;
    e[j] = 0;
  }

  for(p = r[0].next; p ;p = r[p].next){
    j = ord(r[p].keys[i]);
    if(!f[j])
      f[j] = p;
    else
      r[e[j]].next = p;
    e[j] = p;
  }
}

void Collect(SLCell r[],int i,ArrType f,ArrType e)
{
  int j,t;

  for(j = 0; j<RADIX&&!f[j] ; j = succ(j)); //找到第一個(gè)非空子表,succ為求后繼函數(shù)
  if(j<RADIX){
    r[0].next = f[j];
    t = e[j];
    while(j<RADIX){
      for(j = succ(j) ; j<RADIX-1 && !f[j]; j = succ(j));
        if(f[j] && j<=RADIX-1){
          r[t].next = f[j];
          t = e[j];
        }
    }
    r[t].next = 0;
  }

}

void RadixSort(SLList *L)
{
  int i;
  ArrType f,e;

  for(i = 0;i<L->keynum;i++){
    Distribute(L->r,i,f,e);
    Collect(L->r,i,f,e);
  }
}

void CreateSLL(SLList *L)
{
  char s[100];
  int i,n,ct;
  L->recnum = 0;

 /*  printf("請(qǐng)輸入關(guān)鍵字個(gè)數(shù):\n");
  scanf("%d",&L->keynum);
  printf("請(qǐng)輸入鏈表長(zhǎng)度:\n");
  scanf("%d",&n);*/
  L->keynum = 3;
  n = 10;
  printf("依次輸入:278 109 063 963 589 184 505 269 008 083 \n");
  for(ct = 0;ct<n;ct++){
  //  printf("請(qǐng)輸入關(guān)鍵字:\n");

    scanf("%s",&s);
    L->recnum++;
    for(i = 0;i<L->keynum;++i)
      L->r[L->recnum].keys[L->keynum-1-i] = s[i];
  }
  for(i = 0;i<L->recnum;++i)
    L->r[i].next = i+1;
  L->r[L->recnum].next = 0;
}

void TraverseSLL(SLList L)
{
  int i,j;
  for(i = L.r[0].next; i ;i = L.r[i].next){
    for(j = L.keynum-1;j>=0;j--)
      printf("%c",L.r[i].keys[j]);
    printf(" ");
  }
  printf("\n");
}
/*******************************主函數(shù)部分**************************************/
int main()
{
  SLList L;
  printf("創(chuàng)建靜態(tài)鏈表\n");
  CreateSLL(&L);
  printf("創(chuàng)建完成:\n");
  TraverseSLL(L);

  printf("\n基數(shù)排序:\n");
  RadixSort(&L);
  TraverseSLL(L);
  return 0;
}

如有疑問(wèn)請(qǐng)留言或者到本站社區(qū)交流討論,感謝閱讀,希望能幫助到大家,謝謝大家對(duì)本站的支持!

網(wǎng)頁(yè)制作CMS教程網(wǎng)絡(luò)編程軟件編程腳本語(yǔ)言數(shù)據(jù)庫(kù)服務(wù)器

如果侵犯了您的權(quán)利,請(qǐng)與我們聯(lián)系,我們將在24小時(shí)內(nèi)進(jìn)行處理、任何非本站因素導(dǎo)致的法律后果,本站均不負(fù)任何責(zé)任。

聯(lián)系QQ:835971066 | 郵箱:835971066#qq.com(#換成@)

Copyright © 2002-2020 腳本教程網(wǎng) 版權(quán)所有