mall_lucy 于 2016.04.20 22:46 提问

7个回答

caozhy      2016.04.20 22:54
`````` #include <iostream>
using namespace std;
class A
{
public:
void print(int* pData, int count){
for (int i = 0; i< count; i++) {
cout << pData[i] << " ";
}
cout << endl;
}

void BubbleSort(int* pData, int count)
{
int temp;
for (int i = 1; i < count; i++)
{
for (int j = count - 1; j >= i; j--)
{
if (pData[j] < pData[j - 1])
{
temp = pData[j - 1];
pData[j - 1] = pData[j];
pData[j] = temp;
}
}
cout << "The "<< i <<" round:" << endl;
print(pData, count);
cout << "----------------------------" << endl;
}
}
};
int main()
{
int data[] = {10, 8, 9, 7, 4, 5};
A a;
a.BubbleSort(data, 6);
cout << "The sort result:" << endl;
a.print(data, 6);
return 0;
}
``````
mall_lucy   2016.04.20 23:04

caozhy 看不清

mall_lucy   2016.04.20 23:08

caozhy 先把之前的问题采纳了，然后写给你

mall_lucy   2016.04.20 23:08

zhang5476499   2016.04.21 00:23

reeeck   2016.04.21 01:39

#include
#include
using namespace std;

int main(){
int arr_size;
cin>>arr_size; //确定需要输入的数字有多少个
int arr[arr_size];
cout<<"please enter the number sequence: ";
for (int i=0;i cin>>arr[i];
sort(arr,arr+arr_size); //调用STL的排序算法

``````    //display
cout<<"after sort: ";
for (int i=0;i<arr_size;++i)
cout<<arr[i]<<" "<<endl;

return 0;
``````

}

mall_lucy 不用sort行不

CSDNXIAON   2016.04.21 09:44

C++写的一个链表程序

----------------------同志你好，我是CSDN问答机器人小N，奉组织之命为你提供参考答案，编程尚未成功，同志仍需努力！