#include <stdio.h>
#include <stdlib.h>
#define LOW 3
#define LINE 3
search(char a[][LOW], int num)
{
int i = 0;
int j = 0;
for (i = 0; i < LINE; i++)
{
for (j = 0; j < LOW; j++)
{
if (a[i][j] == num)
return 1;
}
}
}
int main()
{
char a[3][3] = { { 1, 2, 3 }, { 4, 5, 6 }, { 7, 8, 9 } };
int num = 0;
int ret = 0;
printf("please input search number:");
scanf("%d", &num);
ret = search(a, num);
if (ret == 1)
printf("exist");
else
printf("not exist");
system("pause");
return 0;
}
(2)
#include <stdio.h>
#include <stdlib.h>
#define LOW 3
#define LINE 3
search(char a[][LOW],int num)
{
int i = 0;
int j = 0;
if (a[1][0] > num)
{
for (i = 0; i < 3; i++)
{
if (a[0][i] == num)
return 1;
}
}
if (a[1][0] < num)
{
for (i = 0; i < 3; i++)
{
if (a[2][i] == num)
return 1;
}
}
}
int main()
{
char a[3][3] = { { 1, 2, 3 }, { 4, 5.6 }, { 7, 8, 9 } };
int num = 0;
int ret = 0;
printf("please input search number:");
scanf("%d", &num);
ret = search(a, num);
if (ret == 1)
printf("exist");
else
printf("not exist");
system("pause");
return 0;
return 0;
}