亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

蟲蟲首頁(yè)| 資源下載| 資源專輯| 精品軟件
登錄| 注冊(cè)

merge_sort

  • merge_sort的一個(gè)示例程序,希望能對(duì)初學(xué)者有所幫助

    merge_sort的一個(gè)示例程序,希望能對(duì)初學(xué)者有所幫助

    標(biāo)簽: merge_sort 程序 初學(xué)者

    上傳時(shí)間: 2016-12-09

    上傳用戶:moerwang

  • this program is merge_sort that writted with c++. this program get an array and sort it in order nl

    this program is merge_sort that writted with c++. this program get an array and sort it in order nlogn.

    標(biāo)簽: program this merge_sort writted

    上傳時(shí)間: 2017-03-23

    上傳用戶:wsf950131

  • c語(yǔ)言算法排序

    1.Describe a Θ(n lg n)-time algorithm that, given a set S of n integers and another integer x, determines whether or not there exist two elements in S whose sum is exactly x. (Implement exercise 2.3-7.) #include<stdio.h> #include<stdlib.h> void merge(int arr[],int low,int mid,int high){      int i,k;      int *tmp=(int*)malloc((high-low+1)*sizeof(int));      int left_low=low;      int left_high=mid;      int right_low=mid+1;      int right_high=high;      for(k=0;left_low<=left_high&&right_low<=right_high;k++)      {      if(arr[left_low]<=arr[right_low]){                                        tmp[k]=arr[left_low++];                                        }      else{           tmp[k]=arr[right_low++];           } }             if(left_low<=left_high){                              for(i=left_low;i<=left_high;i++){                                                               tmp[k++]=arr[i];                                                               }                              }       if(right_low<=right_high){                              for(i=right_low;i<=right_high;i++)                                                                tmp[k++]=arr[i];                                                        }                              for(i=0;i<high-low+1;i++)                                                       arr[low+i]=tmp[i];       } void merge_sort(int a[],int p,int r){      int q;      if(p<r){              q=(p+r)/2;              merge_sort(a,p,q);              merge_sort(a,q+1,r);              merge(a,p,q,r);              }      } int main(){     int a[8]={3,5,8,6,4,1,1};     int i,j;     int x=10;     merge_sort(a,0,6);     printf("after Merging-Sort:\n");     for(i=0;i<7;i++){                      printf("%d",a[i]);                      }     printf("\n");     i=0;j=6;     do{                                    if(a[i]+a[j]==x){                                  printf("exist");                                  break;                                  }                  if(a[i]+a[j]>x)                                 j--;                  if(a[i]+a[j]<x)                                 i++;                       }while(i<=j);     if(i>j)              printf("not exist");     system("pause");     return 0;     }

    標(biāo)簽: c語(yǔ)言 算法 排序

    上傳時(shí)間: 2017-04-01

    上傳用戶:糖兒水嘻嘻

主站蜘蛛池模板: 麻城市| 沐川县| 京山县| 普定县| 依安县| 沾化县| 玉树县| 精河县| 常州市| 张掖市| 沙坪坝区| 波密县| 青海省| 安吉县| 尖扎县| 荃湾区| 镇巴县| 海门市| 磐安县| 左云县| 肥城市| 冕宁县| 房产| 达州市| 南安市| 长沙县| 阜南县| 斗六市| 离岛区| 东城区| 汉寿县| 刚察县| 时尚| 孝感市| 林芝县| 闻喜县| 耿马| 岳西县| 涪陵区| 合水县| 海宁市|