contract FunctionTypes{
function insertSort(int[] memory arr) external returns(int[] memory){
for(int i=1;i<int(arr.length);i++){
int temp=arr[i];
for(int j=i-1;j>=0;j--){
if(arr[j]>=temp) arr[j+1]=arr[j];
else {
arr[j+1]=temp;
}
}
}
return arr;
}
}
在每一行赋值的地方都会报类型错误。我个人的理解是我在参数和变量声明时都声明了类型,为什么还会有类型错误?(不会发图..大家见谅,代码就是简单的插排)
TypeError: Type int256 is not implicitly convertible to expected type uint256.
function insertSort(int[] memory arr) external returns(int[] memory){
for(int i=1;i<int(arr.length);i++){
int temp=arr[i];
for(int j=i-1;j>=0;j--){
if(arr[j]>=temp) arr[j+1]=arr[j];
else {
arr[j+1]=temp;
}
}
}
return arr;
}
}
在每一行赋值的地方都会报类型错误。我个人的理解是我在参数和变量声明时都声明了类型,为什么还会有类型错误?(不会发图..大家见谅,代码就是简单的插排)
TypeError: Type int256 is not implicitly convertible to expected type uint256.