error C2440: “=”: 无法从“void”转换为“int [11]“ 如何更改
#include<iostream>usingnamespacestd;template<classT>voidselectsort(TA[],intn){intsmal...
#include <iostream>
using namespace std;
template<class T>
void selectsort(T A[],int n)
{
int small;
for (int i=0;i<n-1;i++)
{
small=i;
for(int j=i+1;j<n;i++)
if(A[j]<A[small]) small=j;
swap(A[i],A[samll]);
}
}
int main()
{
int A[10]={78,234,25,47,2,3,54,125,6,9};
int arry[11];
for(int i=0;i<11;i++);
arry=selectsort(A,10);
cout<<arry;
return 0;
} 展开
using namespace std;
template<class T>
void selectsort(T A[],int n)
{
int small;
for (int i=0;i<n-1;i++)
{
small=i;
for(int j=i+1;j<n;i++)
if(A[j]<A[small]) small=j;
swap(A[i],A[samll]);
}
}
int main()
{
int A[10]={78,234,25,47,2,3,54,125,6,9};
int arry[11];
for(int i=0;i<11;i++);
arry=selectsort(A,10);
cout<<arry;
return 0;
} 展开
2个回答
展开全部
选择排序?
#include <iostream>
#include <algorithm>
using namespace std;
template<class T>
void selectsort(T A[], size_t const n){
for (size_t i = 0; i != (n - 1); ++i){
size_t small = i;
for (size_t j = i + 1; j != n; ++j){
if (A[j] < A[small]) small = j;
}
swap(A[i], A[small]);
}
}
int main(){
size_t const N = 10;
int A[N] = { 78, 234, 25, 47, 2, 3, 54, 125, 6, 9 };
selectsort(A, N);
for (size_t i = 0; i != N; ++i){
cout << A[i] << " ";
}
cout << "\n";
return 0;
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询