int main(){
int R[]={12,65,11,28,56,68,21};
int a=sizeof(R)/sizeof(R[0]);
InsertSort(R,a);
return 1;
}
int InsertSort(int R[],int n){
}
代码如上,报错如下
9 16 D:\C\test.cpp [Error] 'InsertSort' was not declared in this scope
是因为自定义函数要写在主函数之前,不然就要预先声明
解决方法两种
第一:在int mian() 上面加上这一句话
Void InserSort(int R[],int n)
第二:将自定义函数放在mian函数的前面如下:
int InsertSort(int R[],int n){
}
int main(){
int R[]={12,65,11,28,56,68,21};
int a=sizeof(R)/sizeof(R[0]);
InsertSort(R,a);
return 1;
}