我正在研究气球排序,因为它是我的任务之一,但Google只给我一个气球排序链接样本,其余的是泡泡排序。 我编译开发的C++代码,并说,它有一些错误...气球排序C++
这里[链接](http://www.codemiles.com/c-examples/balloon-sort-algorithm-c-implementation-code-sorting-array-t10823.html)! ,谷歌给了我一个 这里是代码...
#include<iostream>
using namespace std;
void balloon()
{ int num, N[10], x, y, z,temp;
clrscr();
cout<<"How many number would you like to sort? ";
cin>>num;
cout<<"Input the "<<num<<" numbers:"<<endl;
for(x=0;x<num;x++)
cin>>N[x];
for(x=0;x<num;x++)
{
for(y=0;y<num-x;y++)
{ if(N[x] > N[x+y])
{ temp=N[x];
N[x] =N[x+y];
N[x+y]=temp;
}
}
cout<<"pass "<<x+1<<"] ";
for(z=0;z<num;z++)
{
cout<<setw(5)<<N[z];
}
cout<<endl;
}
}
你能帮助我如何气球排序在C++中有一些解释...提前代码谢谢!
等待..我将编辑帖子...我只需要知道如何在此处输入程序在stackoverflow ... – Kolliath01
您缺少两个include语句。做一个编译器找不到的两个函数的websearch,你应该找到文档页面,告诉你需要添加哪些头文件。 – user4581301
您发布的代码只是[选择排序](https://en.wikipedia.org/wiki/Selection_sort)。术语“气球排序”并不常见。在我看到的很少的引用中,有些人说它和冒泡排序类似,有人说它和插入排序类似。但是我看到的几个代码示例显示它是一个简单的选择排序。 –