编译器报错,这啥意思,该如何修改
// 返回引用2.cpp : 此文件包含 "main" 函数。程序执行
#include <iostream>
#include <string.h>
using namespace std;
void sort(int[], int len);
void sort(float[], int len);
void sort(double(), double len);
void show(int iNums[], int len);
void show(float fNums[], float len);
void show(double dNums[], double len);
//参数是数组时,参数是指针
//使用重载实现数组的排序
int main()
{
int iNums[] = { 56,54,12,89,43 };
float fNums[] = { 78.0f,5.7f,42.8f,99.1f };
double dNums[] = { 78.9,23.6,77.3,98.5,33.3 };
cout << "排序前:";
show(iNums, sizeof(iNums) / sizeof(iNums[0]));
show(fNums, sizeof(fNums) / sizeof(fNums[0]));
show(dNums, sizeof(dNums) / sizeof(dNums[0]));
cout << "排序后:";
sort(iNums, sizeof(iNums) / sizeof(iNums[0]));
sort(fNums, sizeof(fNums) / sizeof(fNums[0]));
sort(dNums, sizeof(dNums) / sizeof(dNums[0]));
show(iNums, sizeof(iNums) / sizeof(iNums[0]));
show(fNums, sizeof(fNums) / sizeof(fNums[0]));
show(dNums, sizeof(dNums) / sizeof(dNums[0]));
}
void sort(int num[], int len)
{
int temp;
for (int i = 0; i < len - 1; i++)
{
for (int j = 0; j < len - i - 1; j++)
{
if (num[j] > num[j])
{
temp = num[j];
num[j] = num[j + 1];
num[j + 1] = temp;
}
}
}
}
void sort(float num[], int len)
{
float temp;
for (int i = 0; i < len - 1; i++)
{
for (int j = 0; j < len - i - 1; j++)
{
if (num[j] > num[j])
{
temp = num[j];
num[j] = num[j + 1];
num[j + 1] = temp;
}
}
}
}
void sort(double num[], double len)
{
double temp;
for (int i = 0; i < len - 1; i++)
{
for (int j = 0; j < len - i - 1; j++)
{
if (num[j] > num[j])
{
temp = num[j];
num[j] = num[j + 1];
num[j + 1] = temp;
}
}
}
}
void show(int iNums[], int len)
{
for (int i = 0; i < len; i++)
{
cout << iNums[i] << '\t';
}
cout << endl;
}
void show(float fNums[], float len)
{
for (int i = 0; i < len; i++)
{
cout << fNums[i] << '\t';
}
cout << endl;
}
void show(double dNums[], double len)
{
for (int i = 0; i < len; i++)
{
cout << dNums[i] << '\t';
}
cout << endl;
}