气泡排序错误LNK2019
BubbleSort error LNK2019
这是我的cpp代码和错误,我得到
错误LNK2019:无法解析的外部符号"void __cdecl selectionSort(int * const,int &,int &)"(?selectionSort@@YAXQAHAAH1@Z)引用函数_main
#include <iostream>
using namespace std;
void bubbleSort(int[], int&, int&);
void inserionSort (int [], int&, int&);
void generateRandomArray ( int [], int [], int []);
void selectionSort (int[], int&, int&);
const int length=5000;
int main()
{
int compBubbleSort =0;
int assignBubbleSort=0;
int list1[length], list2 [length], list3[length];
generateRandomArray( list1, list2, list3);
cout<<"****************Bubble sort*****************"<<endl;
bubbleSort( list1, compBubbleSort, assignBubbleSort);
cout<<endl;
cout<<"Number of compBubbleSort are :"<< compBubbleSort<<endl;
cout<<"Number of Assignments are :"<< assignBubbleSort<<endl;
cout<<endl;
compBubbleSort = 0;
assignBubbleSort = 0;
cout<<"**********Selection sort***************"<<endl;
cout<<endl;
selectionSort (list2, compBubbleSort, assignBubbleSort);
cout<<"Number of compBubbleSort are:"<< compBubbleSort <<endl;
cout<<"Number of Assignments are :"<< assignBubbleSort<<endl;
cout<<endl;
compBubbleSort=0;
assignBubbleSort=0;
cout<<"****************Insertion sort*******************"<<endl;
cout<<endl;
inserionSort (list2, compBubbleSort, assignBubbleSort);
cout<<"Number of compBubbleSort are:"<< compBubbleSort <<endl;
cout<<"Number of Assignments are :"<< assignBubbleSort<<endl;
system ("pause");
return 0;
}
void generateRandomArray( int list1[], int list2 [], int list3[])
{
srand(time_t(0));
for(int i=0; i<length; i++)
list1 [i]= list2[i]= list3[i]=rand()%20000;
}
void bubbleSort (int num[], int &compBubbleSort, int &assignBubbleSort)
{
for(int iter=1; iter<length; iter++)
{
for(int index=1; index<length; index++)
{
compBubbleSort++;
if(num [index]>num[index+1])
{
int temp= num[index];
num[index] = num[index+1];
num[index+1]=temp;
assignBubbleSort++;
}
}
}
}
void seletionSort( int num[], int &compBubbleSort, int &assignBubbleSort)
{
int index;
int smallestIndex;
int location;
int temp;
for (index=0; index<length-1; index++)
{
smallestIndex=index;
for(location=index+1;location<length;location++)
{
compBubbleSort++;
if(num[location]<num[smallestIndex])
{
smallestIndex=location;
}
}
temp= num[smallestIndex];
num[smallestIndex] =num[index];
assignBubbleSort= assignBubbleSort+3;
num[index] = temp;
}
}
void inserionSort (int num[], int &compBubbleSort, int&assignments)
{
int firstOutOfOrder,location;
int temp;
for (firstOutOfOrder=1; firstOutOfOrder<length;firstOutOfOrder++)
{
if(num[firstOutOfOrder]<num[firstOutOfOrder-1])
{
compBubbleSort++;
temp= num[firstOutOfOrder];
location=firstOutOfOrder;
assignments=assignments+2;
do
{
num[location]=num[location-1];
assignments++;
location--;
compBubbleSort++;
}
while(location>0 &&num[location-1]>temp);
num[location]=temp;
assignments++;
}
}
}
谁能解释一下错误2019,因为我的大多数程序都有。
函数定义中有一个错别字
改变:
void seletionSort( int num[], int &compBubbleSort, int &assignBubbleSort)
:
void selectionSort( int num[], int &compBubbleSort, int &assignBubbleSort)
// ^
链接器找不到selectionSort
相关文章:
- 链接CPP文件进行测试时发生LNK2019错误
- 32位到64位:LNK2019错误,如何检索相关信息
- 在结构函数之间传递文件路径 C++ 编辑:修复LNK2019错误
- 尝试使用 TMXlite 编译项目时LNK2019错误
- LNK2019错误;此处缺少/未定义的内容
- DX11 DirectInput8创建引起LNK2019错误
- C++ mysql 仅在构建解决方案时LNK2019错误
- C LNK2019错误,未解决的外部字符
- C++ 带有出现LNK2019错误的对象的链接列表
- 解决 main 中的LNK2019错误
- 尝试使用命名空间中的函数时LNK2019错误
- LNK2019错误未解析的外部符号
- LNK2019错误,在Visual Studio 2012 C++的main中使用的函数
- 同一项目中两个类之间的visual c++LNK2019错误
- LNK2019错误(未解析的外部符号)将SQLite链接到DLL
- C++/CLI 包装器LNK2028和LNK2019错误
- LNK2019错误,尝试覆盖运算符<< 对于 LinkedList 类
- LNK2001和LNK2019错误 - DirectX 未解析的外部符号
- (2012)Visual C++LNK2019错误,可能是模板问题
- LNK2019错误一个DLL链接到MFC DLL