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

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? rsort.cpp

?? 一種排序算法
?? CPP
字號:
//////////////////////////////////
// Rapid Sort & Function Templates
// By: *LuckY*
// lucky760@yahoo.com
//////////////////////////////////
// perhaps I over-commented

#include <iostream>
using namespace std;
#include <cstring> //for the strlen() function

/* function prototypes */

//function template (discussed later) to display
//the contents of any generic array by passing
//the address of the first element and the number
//of elements in the array. this is much better
//than using a bunch of 'for' loops with 'cout's
template <typename T>
void show(const T*,int);

//pass the array and the number of elements to the
//intermediary function. it will format the arguments
//properly and pass them to the actual sort procedure
template <typename T>
void r_sort(T*,int);

//the actual sort procedure. it takes the array, the 
//index of its first element, and the index of its last
//element
template <typename T>
void do_r_sort(T*,int,int);

int main() {
  //I'm hard-coding this array of char here, when in fact you 
  //can use any generic array (ie: int,short,long,float,double)
  //because the function template allows you to do so
  char chr[] = "The quick brown fox jumped over the lazy dogs.";  

  show(chr,strlen(chr)); //display the original array

  r_sort(chr,strlen(chr)); //do the sorting

  show(chr,strlen(chr)); //display the newly sorted array

  return 0;
}

template <typename T>
void r_sort(T *list,int count) {
  //pass the beginning values to the do_r_sort function
  //the first index is always 0 and the index of the last
  //index is 1 less than the element count, which is why
  //we have 'count-1'
  //if we didn't use this intermediary, we'd have to make 
  //ugly function calls to the do_q_sort function from the
  //main program. we don't want that.
  do_r_sort(list,0,count-1);
}

template <typename T>
void show(const T *arr,int num) {
  //from the first to the last elements of the given array
  //we do a cout. I commented out the " " because we
  //are dealing with a string, so we don't want spaces 
  //between each letter, but if it was a numeric array, we'd
  //want to leave it in.
  for (int i=0;i<num;++i) 
    cout << arr[i] /*<< " "*/;
  cout << endl;
}  

template <typename T>
void do_r_sort(T *arr,int basel,int baser) {
  //type T is the type which was passed to the function
  //so in the case of this example, type T is 'char'
  //if you passed an array of double, T would be 'double' etc...
  T temp;
  int biggest,smallest;
  
  /* find the biggest element */
  //this will start 'left' at the 'basel' index and 'right' at
  //the 'baser' value. if the value at index left is greater
  //than the one at right, we move index right to the left one
  //element and vice versa. we continue this until left and
  //right meet. In other words, we will keep moving the index
  //of the smaller value until both indexes meet. this will
  //assign the index to variable 'biggest'
  //(side note: there's no 3rd element in the 'for' loop 
  // because we do the update of left and right in the body)
  for (int left=basel,right=baser;left<right; )
    biggest = arr[left] >= arr[right] ? --right : ++left;

  /* place biggest at end of array */
  //here we copy the last value of the array to a temp variable
  //then we put the biggest value (of the entire array) into the
  //last (or rightmost) element because we are sorting for
  //left to right -- smallest to biggest
  //then we put the temp value into the slot where the 'biggest'
  //one just was. IOW, we swap the biggest value with the last
  //element's value
  temp = arr[baser];
  arr[baser] = arr[biggest];
  arr[biggest] = temp;

  /* find the smallest element */
  //same as above except for the smallest element
  for (int left=basel,right=baser;left<right; )
    smallest = arr[left] <= arr[right] ? --right : ++left;

  /* place smallest at head of array */
  temp = arr[basel];
  arr[basel] = arr[smallest];
  arr[smallest] = temp;

  //we move the baser value in one from the right and
  //the basel value in one from the left then we check to see
  //if there are still some elements in between the two indexes
  //that need to be sorted. if there are, the function calls 
  //itself passing only the new scope of the array because
  //we don't have to check the leftmost value and the rightmost
  //as we already know that they are not out of order.
  //this is recursion -- the function calling itself -- and it
  //will continue until there is nothing more to sort
  --baser;
  ++basel;
  if (basel < baser) 
    do_r_sort(arr,basel,baser);
}

/*A little bit about function templates:
  The syntax for a function template is this

    template <typename [name of generic type]>
    [return type] [function name] ([argument list]);

  This is used for the function prototype and the definition. The
  'name of generic type' as specified on the template line MUST be
  used in the argument list at least once.
  Then when you use the variables of the passed type in your function,
  you use the same typename that you specified. So, if we said:

    template <typename Blah> //etc..

  we would do a:

    Blah x;

  to declare a variable of the same type that was passed.
  The function template is actually just a blueprint for the compiler.
  No code is actually created from the code of the template. Once you
  pass something to the function, lets say a 'double' value, the
  compiler will read the blueprint and create an instantiation, or the
  actual 'double' code that will do the procedure of the template as
  specified.
*/

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产一区在线观看视频| 一区二区三区在线免费视频 | 99国产精品久久久久久久久久 | 性久久久久久久久| 欧美日韩精品欧美日韩精品一 | 在线免费不卡电影| 一区二区三区蜜桃| 欧美日韩大陆一区二区| 三级在线观看一区二区| 2021中文字幕一区亚洲| 成人毛片在线观看| 亚洲成在线观看| 久久理论电影网| 99国产欧美久久久精品| 亚洲成人av一区二区三区| 欧美大片拔萝卜| 成人av影视在线观看| 亚洲一卡二卡三卡四卡五卡| 欧美一区二区三区在线| 国产精一品亚洲二区在线视频| 久久中文字幕电影| 91浏览器打开| 另类人妖一区二区av| 国产精品你懂的| 欧美日韩国产乱码电影| 国产精品主播直播| 亚洲电影第三页| 国产亚洲成av人在线观看导航| 成人a级免费电影| 日韩成人一区二区三区在线观看| 日韩色视频在线观看| eeuss鲁片一区二区三区在线看| 亚洲激情在线激情| 久久久久久久免费视频了| 一本久道中文字幕精品亚洲嫩| 日韩高清在线电影| 国产精品乱人伦一区二区| 欧美精品一二三| a美女胸又www黄视频久久| 免费观看成人av| 亚洲精选免费视频| 国产视频一区在线观看| 在线不卡一区二区| 91美女精品福利| 国产精品一区二区在线观看网站| 亚洲黄色尤物视频| 国产精品美女视频| 欧美精品一区二| 欧美精品在欧美一区二区少妇| 国内成+人亚洲+欧美+综合在线| 国产精品久久久久久久久久免费看| 欧美艳星brazzers| eeuss鲁片一区二区三区| 久久草av在线| 午夜精品免费在线| 一区二区三区 在线观看视频| 日韩精品一区二区在线观看| 欧美日韩中字一区| 91国模大尺度私拍在线视频| 国产成人在线色| 美女视频免费一区| 日韩中文字幕区一区有砖一区 | aa级大片欧美| 国产黄色成人av| 国内精品在线播放| 理论片日本一区| 日韩高清在线一区| 日韩av一二三| 婷婷国产在线综合| 亚洲大片在线观看| 午夜精品国产更新| 亚洲国产精品嫩草影院| 亚洲精品国产无天堂网2021| 亚洲欧美影音先锋| 亚洲素人一区二区| 亚洲视频一区在线观看| 国产精品―色哟哟| **欧美大码日韩| 国产精品久99| 日韩伦理电影网| 亚洲免费观看在线视频| 亚洲欧美日韩国产手机在线| 亚洲视频图片小说| 亚洲欧美成人一区二区三区| 综合av第一页| 一区二区三区视频在线看| ...xxx性欧美| 亚洲夂夂婷婷色拍ww47| 午夜久久久久久| 久久99热国产| 不卡一区二区三区四区| 色综合久久久网| 欧美三级中文字| 91麻豆精品国产91久久久久久久久 | 亚洲最大成人网4388xx| 亚洲综合免费观看高清完整版在线| 国产欧美一区二区精品性色| 中文字幕免费观看一区| 亚洲你懂的在线视频| 亚洲一区二区不卡免费| 麻豆国产一区二区| 成人午夜私人影院| 在线一区二区三区做爰视频网站| 在线观看免费成人| 欧美videossexotv100| 国产日韩在线不卡| 亚洲黄一区二区三区| 六月丁香婷婷色狠狠久久| 国产精品69毛片高清亚洲| 色综合久久久久综合体| 欧美久久婷婷综合色| 久久久久久久久久久黄色| 日韩美女视频一区二区| 日本美女一区二区三区视频| 国产.欧美.日韩| 欧美日韩高清一区二区| 国产日韩影视精品| 日韩中文字幕区一区有砖一区| 九九**精品视频免费播放| 99国产一区二区三精品乱码| 91麻豆精品国产91久久久久久 | 欧美一区二区三区在线| 国产精品三级视频| 免费看日韩a级影片| av午夜一区麻豆| 精品动漫一区二区三区在线观看| 欧美国产精品一区二区三区| 亚洲二区视频在线| 成人黄色国产精品网站大全在线免费观看| 成人国产精品免费观看| 91精品福利在线一区二区三区 | 欧美精选午夜久久久乱码6080| 久久香蕉国产线看观看99| 一区二区三区 在线观看视频| 麻豆精品新av中文字幕| 在线免费观看日本一区| 久久精品水蜜桃av综合天堂| 日韩在线观看一区二区| 色综合夜色一区| 国产精品私人影院| 一本色道久久综合精品竹菊| 日韩精品一区二区三区视频播放| 国产精品天干天干在观线| 久草精品在线观看| 欧美另类一区二区三区| 亚洲精品视频免费看| 从欧美一区二区三区| 精品av久久707| 美女高潮久久久| 91.xcao| 亚洲综合免费观看高清完整版在线 | 精品乱码亚洲一区二区不卡| 国产精品久久久久久久久果冻传媒 | 91麻豆123| 中文一区在线播放| 国产精品一二三在| 26uuu国产日韩综合| 黄色小说综合网站| 5566中文字幕一区二区电影| 午夜电影网亚洲视频| 欧美主播一区二区三区美女| 综合激情成人伊人| 91美女片黄在线观看91美女| 亚洲欧洲成人精品av97| 99久久精品国产网站| 中文字幕视频一区| 91色乱码一区二区三区| 亚洲精品菠萝久久久久久久| 色94色欧美sute亚洲线路二| 亚洲卡通动漫在线| 欧美亚洲一区二区在线| 亚洲国产一区二区视频| 欧美日韩国产另类不卡| 日韩精品高清不卡| 日韩欧美国产电影| 国产一区二区三区久久久| 久久伊人中文字幕| 福利电影一区二区| 日韩美女视频19| 欧美日韩国产成人在线免费| 亚洲一区二区偷拍精品| 欧美精品xxxxbbbb| 美女网站在线免费欧美精品| 久久人人爽人人爽| 成人在线视频首页| 亚洲精品一卡二卡| 69久久99精品久久久久婷婷| 蜜芽一区二区三区| 久久久久久久久久美女| 99久久免费视频.com| 亚洲一区二区欧美| 精品国免费一区二区三区| 国产99久久久国产精品潘金| 亚洲乱码国产乱码精品精98午夜 | 欧美国产精品v| 欧洲在线/亚洲| 激情综合色播激情啊| 中文字幕一区二区三区乱码在线| 99视频一区二区| 日韩电影在线一区二区|