Wyskakuje mi błąd :identifier "t" is undefined; 't': undeclared identifier. Nie wiem co w tym kodzie jest nie tak i jak to poprawić.
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <iostream>
using namespace std;
#define MAX 100
int HalfFind (int t[], int nSize, int x);
int main()
{
cout << "Podaj liczbe szukana: ";
int x;
cin >> x;
int ix = HalfFind (t, MAX, x);
if (ix == -1)
{
cout << "elementu" << x << " nie ma w tablicy\n";
}
else
{
cout << "element " << x << "wystepuje pod indeksem: " << ix;
cout << "\n\n";
return 0;
}
}
int HalfFind(int t[], int nSize, int x)
{
int l = 0;
int p = nSize - 1;
do
{
int m = (1 + p) / 2;
if (x < t[m])
p = m + 1;
else if (x > t[m])
l = m + 1;
else return m;
} while (l <= p);
return -1;
}