C 在while循环中获取错误'&燃气轮机';:不从';int';至';int*';

C 在while循环中获取错误'&燃气轮机';:不从';int';至';int*';,c,recursion,insertion-sort,C,Recursion,Insertion Sort,我正在使用Microsoft Visual Studio编译代码。我在while循环中为条件a[I]>k得到这个错误: “>”:没有从“int”到“int*”的转换 代码如下: /* Sort the array using Recursive insertion sort */ #include <stdio.h> #include <conio.h> void RecursiveInsertionSort(int a[], int); /* Recursively

我正在使用Microsoft Visual Studio编译代码。我在while循环中为条件
a[I]>k
得到这个错误:

“>”:没有从“int”到“int*”的转换

代码如下:

/* Sort the array using Recursive insertion sort */
#include <stdio.h>
#include <conio.h>

void RecursiveInsertionSort(int a[], int);

/* Recursively call the function to sort the array */
void RecursiveInsertionSort(int *a, int n) 
{
    int i,k;
    if (n > 1)
        RecursiveInsertionSort(a, n - 1);//Call recursively
    else {
        k = a[n];
        i = n - 1;
        while (i >= 0 & &  a[i] > k){ 
            a[i + 1] = a[i]; //replace the bigger
            i = i - 1;
        }
        a[i + 1] = k; //Place the key in its proper position
    }
}

/* Main function */
void main()
{
    int a[] = { 5,4,3,2,1 }; // Array unsorted declared
    RecursiveInsertionSort(a, 5);//call recursive function to sort the array in ascending order
}
/*使用递归插入排序对数组进行排序*/
#包括
#包括
void RecursiveInsertionSort(int a[],int);
/*递归调用函数对数组进行排序*/
void RecursiveInsertionSort(int*a,int n)
{
int i,k;
如果(n>1)
RecursiveInsertionSort(a,n-1);//递归调用
否则{
k=a[n];
i=n-1;
而(i>=0&&a[i]>k){
a[i+1]=a[i];//替换较大的
i=i-1;
}
a[i+1]=k;//将钥匙放在正确的位置
}
}
/*主要功能*/
void main()
{
int a[]={5,4,3,2,1};//声明了未排序的数组
RecursiveInsertionSort(a,5);//调用递归函数以升序对数组排序
}

有人能帮我理解错误吗?

逻辑运算符
&&
中有一个空格:

while (i >= 0 & &  a[i] > k){ 
这相当于

while (i >= 0 & &a[i] > k) {
它是介于
i>=0
&a[i]>k
(两个布尔值)之间的按位AND运算


&a[i]>k
比较
a[i]
(一个
int*
)和
k
(一个
int
)的地址。因此出现了错误。

这是符号和之间的空格吗?谢谢..愚蠢的错误