#include <iostream.h>
int* location(int[],int,int);
void main()
{ int a[8] = {22, 33, 44, 55, 66, 77, 88, 99}, * p=0, n;
do
{ cin >> n;
if (p == location(a, 8, n)) cout << p << ", " << *p << endl;
else cout << n << " was not found.\n";
} while (n > 0);
}
int* location(int a[], int n, int target)
{ for (int i = 0; i < n; i++)
if (a[i] == target) return &a[i];
return NULL;
}
0 comments:
Post a Comment