//冒泡排序
void BubbleSort(ElemType A[], int n) {
int i, j, temp;
int flag=1;
for (i = 1; i <= n - 1&&flag; i++) {
flag = 0;//表示在本趟冒泡是否发生交换的标志
for (j = 1; j <= n - i; j++)
if (A[j] > A[j + 1]) {
temp = A[j];
A[j] = A[j + 1];
A[j + 1] = temp;
flag = 1;//发生交换
}
if (flag == 0)
return;
}
}
//快速排序
int QKPass(ElemType A[], int low, int high) {
ElemType pivot = A[low];
while (low < high)
{
while (low < high && A[high] >= pivot) --high;
A[low] = A[high];
while (low < high && A[low] <= pivot) ++low;
A[high] = A[low];
}
A[low] = pivot;
return low;
}
void QuickSort(ElemType A[], int low, int high) {
if (low < high) {
int pivotpos = QKPass(A, low, high);
QuickSort(A, low, pivotpos - 1);
QuickSort(A, pivotpos + 1, high);
}
}
void InputA(int* A, int n) {
int i;
for (i = 1; i <= n; i++) {
scanf_s("%d", &A[i]);
}
}
void PrintA(int *A,int n) {
for (int i = 1; i <= n; i++) {
printf("%2d", A[i]);
}
}
int main() {
int low = 0, high = 7;
int A[100];
InputA(A, 8);
//BubbleSort(A, 8);
//ShellSortw(A, 8);
//BinSort(A, 8);
InsertSort(A, 8);
for (int i = 1; i <= 8; i++) {
printf("%2d", A[i]);
}
system("pause");
return 0;
}

最新文章

  1. Unity3D 脚本手册
  2. js 将json字符串转换为json兑现
  3. 一.JSP开发的工具下载与环境搭建
  4. bzoj3878
  5. iReport中求和的问题
  6. Extjs4 关于设置form中所有子控件为readOnly属性的解决方案
  7. Eclipse+Pydev +Django搭建开发环境时容易出错的几点
  8. Python函数化编程整理
  9. iTools(pro)下载
  10. JavaScript简单简介
  11. git 的相关知识
  12. Matlab function lorenzgui
  13. 洗礼灵魂,修炼python(60)--爬虫篇—httplib2模块
  14. Nightmare HDU1072
  15. 解决com.microsoft.sqlserver.jdbc.SQLServerException: 该连接已关闭
  16. 带你走进EJB--将EJB发布为Webservice(3)
  17. bzoj 4927: 第一题
  18. JAVA 判断字符串是否可转化为JSONObject、JSONArray
  19. lua 中的 loadfile、dofile和require的调用
  20. 【Cocos2d-x】Cocos2d-x跨Android平台搭建之四:Win7 64位+ eclipse + cocos2dX

热门文章

  1. selenium注入js代码
  2. nexus私服搭建的上传和下载
  3. 【一句话】 OAuth 2
  4. 亲测有效! Scrutiny 网站SEO检测及优化工具 V12.6.1 for mac
  5. Android 初代 K-V 存储框架 SharedPreferences,旧时代的余晖?
  6. 【KAWAKO】iphone13pro开箱流程
  7. Loadrunner性能测试简记
  8. 与 Flutter 共创未来 | Flutter Forward 活动精彩回顾
  9. ubuntu 20.04 远程桌面(win10 控制 Ubuntu 20.04)
  10. Vue学习笔记之表单绑定