惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Forbes - Security
Forbes - Security
GbyAI
GbyAI
WordPress大学
WordPress大学
小众软件
小众软件
Y
Y Combinator Blog
The GitHub Blog
The GitHub Blog
S
SegmentFault 最新的问题
A
About on SuperTechFans
月光博客
月光博客
F
Fortinet All Blogs
宝玉的分享
宝玉的分享
Microsoft Security Blog
Microsoft Security Blog
大猫的无限游戏
大猫的无限游戏
Hugging Face - Blog
Hugging Face - Blog
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
V
V2EX
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
N
Netflix TechBlog - Medium
Jina AI
Jina AI
博客园 - 聂微东
Schneier on Security
Schneier on Security
云风的 BLOG
云风的 BLOG
博客园 - 司徒正美
N
News | PayPal Newsroom
PCI Perspectives
PCI Perspectives
Last Week in AI
Last Week in AI
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
P
Proofpoint News Feed
Hacker News: Ask HN
Hacker News: Ask HN
B
Blog
aimingoo的专栏
aimingoo的专栏
P
Privacy International News Feed
Martin Fowler
Martin Fowler
罗磊的独立博客
H
Hackread – Cybersecurity News, Data Breaches, AI and More
NISL@THU
NISL@THU
Know Your Adversary
Know Your Adversary
C
Cybersecurity and Infrastructure Security Agency CISA
博客园 - 叶小钗
N
News and Events Feed by Topic
T
The Exploit Database - CXSecurity.com
Stack Overflow Blog
Stack Overflow Blog
S
Security @ Cisco Blogs
D
Darknet – Hacking Tools, Hacker News & Cyber Security
V
Vulnerabilities – Threatpost
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
T
Threatpost
IT之家
IT之家
B
Blog RSS Feed

博客园 - 无痕的泪

任务栏不显示任务、不能有文件拖动、粘贴操作 登陆qq.电脑重启 WEB测试之兼容性测试 如何编写测试计划 boot disk failure,insert system disk and press enter 使用数组的方法,解决Josephus问题 - 无痕的泪 - 博客园 网游名字-调查 赖子山庄工作记录 软件测试面试题目————征求更好答案 比google 百度 更强(http://www.new1000.cn ) google sitemap 介绍(转载) server 2003 directx被禁用 Sql server 2005 的安装 loadrunner的安装 LoadRunner8.1 安装汉化 出错 软件测试准备(摘要) 网站测试方法 软件测试(分类,方法,工具) 软件测试分类
quick sort 快速排序法
无痕的泪 · 2008-10-31 · via 博客园 - 无痕的泪

#include<iostream.h>

void qsort(int [],int,int);

void main()                    //quick sort 快速排序法
{
 int array[]={3,32,332,4,2,34,23,4,2,423};
 int len=sizeof(array)/sizeof(int);
 for(int i=0;i<len;i++)       //原始结果输出
  cout<<array[i]<<",";
 cout<<endl;

 qsort(array,0,len-1);

 for(int j=0;j<len;j++)         //排序结果输出
  cout<<array[j]<<",";
 cout<<endl;
}

void qsort(int a[],int left,int right)
{
 int pivot,l,r,temp;
 l=left;
 r=right;
 pivot=a[(left+right)/2];

 while(l<r)
 {
  while(a[l]<pivot) ++l;
  while(a[r]>pivot) --r;

  if(l>=r) break;

  temp=a[l];
  a[l]=a[r];
  a[r]=temp;

  if(l!=pivot) --r;
  if(r!=pivot) ++l;
 }
 if(l==r) l++;
 if(left<r) qsort(a,left,l-1);
 if(l<right) qsort(a,r+1,right);
}