- 2
- 0
- 约小于1千字
- 约 2页
- 2023-12-06 发布于上海
- 举报
313页第2题
#ifndefbubbleup_h#definebubbleup_htemplatetypenameBclassBubble_up
{
inti,j,k,m,n;
BA[30000],l;
public:
Bubble_up(Ba[])
{
i=0;
while(a[i]!=-1)
{
A[i]=a[i];i++;
}
}
voidBefore_sorting_print()
{
j=0;
cout排序前:endl;while(j!=i)
{
coutA[j];j++;
}
coutendl;
}
voidsorting()
{
for(j=0;ji;j++)
for(k=i-1;kj;k--)
if(A[k-1]A[k])
{
l=A[k-1];A[k-1]=A[k];A[k]=l;
}
cout排序完成!endl;
}
voidAfter_sorting_print()
{
j=0;
cout排序后:endl;while(j!=i)
{
coutA[j];j++;
}
}
};
#endif
#includeiostreamusingnamespacestd;#includebubbleup.h#includestring
intmain()
{
intarray[30000],i=0,j=0;
原创力文档

文档评论(0)