我的程序应该订购一个由用户输入的数字列表,但它甚至在到达第一个printf之前就崩溃了.我的编译器发出2个警告,但我没有看到问题.我还没有研究过指针,所以我不想使用它们.以下是消息:
在函数`selection_sort'中:
[Warning] passing arg 2 of `selection_sort' makes pointer from integer without a cast
Run Code Online (Sandbox Code Playgroud)
在函数`main'中:
[Warning] passing arg 2 of `selection_sort' makes pointer from integer without a cast
Run Code Online (Sandbox Code Playgroud)
.
#include<stdio.h>
int selection_sort(int n, int v[n])
{
int high = v[0];
int i;
for(i = 0; i < n; i++)
high = high < v[i]? v[i] : high;
if(n - 1 == 0)
return;
v[n - 1] = high;
n -= 1;
selection_sort(n, v[n]);
}
int main(void)
{
int n, …Run Code Online (Sandbox Code Playgroud)