Я использую Microsoft Visual Studio для компиляции кода. Я получаю эту ошибку в цикле в то время как для условия a[i] > k
:Получение ошибки во время цикла '>': Нет преобразования из 'int' в 'int *'
'>': Нет преобразование из '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
}
Может кто-нибудь, пожалуйста, помогите мне понять ошибку?
Это пространство между амперсандами? – Li357
спасибо..Уверенная ошибка – Sandeep