int readfile2D()
{
int a[20];
int i;
FILE* fp = fopen("C:\\Users\\Administrator\\Desktop\\Table.txt", "r");
if (fp == NULL)
{
printf("文件无效");
return -1;
}
for (i = 0; i<20; i++)
fscanf(fp, "%d", &a);
fclose(fp);
for (i = 0; i<20; i++)
printf("%d ", a);
printf("\n");
return 0;
}
int _tmain(int argc, char *argv[])
{
readfile2D();
getchar();
//return 0;
}
//int a[20];
int b[20];
int maxmin(int a[], int b[], int size_a, int size_b)
{
int i = 0, j = 0;
for (i = 0; i < size_a - 1;)
{
while (a < a[i + 1])
{
i++;
}
b[j++] = a;
if (j >= size_b)
return j;
while (a > a[i + 1])
{
i++;
}
b[j++] = a;
if (j >= size_b)
return j;
}
}
int main1(int a[], int b[], int argc, char **argv)
{
int i = 0, j = 0;
j = maxmin( a, b, 20, 8);
for (i = 0; i < 8; i++)//
{
printf("b[%d] = %d\n", i, b);
}
printf("\n");