排序问题
想调用函数为数组排序,编译连接完后,输入五个数回车没有结果,还提示错误,源程序如下,我是出学,高手指点下.
#include<iostream>
using namespace std;
int ascend(int a[5]);
int main()
{
int a[5];
cout<<"Input 5 numbers:"<<endl;
cin>>a[0]>>",">>a[1]>>",">>a[2]>>",">>a[3]>>",">>a[4];
ascend(a);
return 0;
}
int ascend(int b[5])
{
for(int i=1;i<5;i++)
for(int j=1;j<=5-i;j++)
if(b[j]>b[j+1])
{
int tmp=b[j];
b[j]=b[j+1];
b[j+1]=tmp;
}
for(int m=1;m<5;m++)
{
cout<<b[m];
}
return 0;
}