#include<iostream>
#include<conio.h>
using namespace std;
int main()
{
int a, b, c[5], d;
cout << "enter any five number\n";
for(a=0; a<5; a++)
{
cin>>c[a];
}
for(a=0; a<5; a++)
{
for(b=++a; b<5; b++)
{
if(c[b] < c[a])
{
d = c[b];
c[b] = c[a];
c[a] = d;
}
}
}
cout << "\nhere is the entered numbers in order\n";
for(a=0; a<5; a++)
{
cout << c[a];
cout << endl;
}
getch();
return 3;
}
我在桌面上檢查這個程序,我希望程序按升序對數字進行排序,但是我得到了錯誤的輸出幫助。排序算法給出錯誤結果
,不,不,不@MarounMaroun我很抱歉,如果它是一個壞習慣,這是我的最後一次。 – samuel
你不能只使用std :: sort嗎? – Ralara
@Ralara:標題的原始格式確實表明這是一項作爲練習指定的任務 – quetzalcoatl