/* C Programming, Project 8 */
#include <stdio.h>
#include <stdlib.h>
#define SIZE 26
void getMax(double *, double *);
void getMin(double *, double *);
int main(void)
{
double A[][SIZE] = {{617, 90, 195, 813, 697, 81, 435, 202, 594, 109, 486, 778, 743, 335, 881, 427, 931, 81, 81, 275, 108, 282, 812, 95, 325, 0},
{699, 392, 915, 757, 487, 614, 449, 354, 895, 107, 526, 147, 606, 233, 459, 16, 866, 226, 353, 923, 839, 776, 120, 5, 909, 0},
{83, 576, 846, 468, 52, 983, 279, 101, 489, 646, 337, 168, 93, 755, 143, 38, 72, 849, 876, 3, 928, 326, 496, 623, 907, 0},
{243, 704, 460, 820, 487, 924, 273, 911, 849, 405, 686, 251, 534, 491, 772, 248, 47, 118, 588, 770, 496, 421, 472, 858, 886, 0},
{415, 575, 245, 3, 629, 405, 81, 224, 209, 457, 927, 820, 929, 650, 723, 712, 258, 245, 351, 458, 788, 539, 6, 752, 756, 0},
{882, 856, 909, 501, 59, 823, 233, 250, 935, 720, 997, 676, 909, 221, 648, 606, 28, 326, 35, 846, 429, 766, 116, 513, 706, 0},
{239, 824, 122, 401, 99, 877, 570, 494, 895, 395, 550, 820, 371, 798, 635, 695, 218, 995, 931, 374, 37, 350, 25, 351, 500, 0},
{408, 214, 972, 907, 975, 117, 388, 44, 443, 821, 647, 112, 850, 484, 844, 428, 183, 662, 474, 99, 434, 305, 176, 48, 799, 0},
{859, 772, 186, 140, 670, 890, 800, 419, 549, 339, 311, 246, 235, 568, 279, 810, 777, 576, 978, 989, 231, 16, 159, 735, 594, 0},
{855, 689, 199, 253, 67, 104, 686, 925, 756, 117, 346, 203, 552, 774, 932, 495, 693, 302, 146, 181, 183, 596, 742, 196, 937, 0},
{658, 730, 199, 707, 569, 844, 261, 452, 547, 816, 202, 249, 167, 130, 236, 273, 322, 480, 452, 581, 608, 873, 803, 47, 142, 0},
{538, 362, 661, 202, 412, 907, 948, 4, 317, 410, 22, 488, 866, 188, 921, 733, 752, 6, 606, 378, 894, 175, 820, 911, 909, 0},
{509, 764, 938, 263, 977, 433, 928, 800, 213, 679, 130, 248, 898, 783, 557, 255, 246, 498, 721, 862, 786, 104, 293, 532, 496, 0},
{857, 515, 845, 317, 249, 11, 190, 751, 294, 551, 791, 658, 389, 988, 625, 95, 336, 301, 157, 439, 486, 502, 871, 697, 124, 0},
{649, 325, 747, 697, 771, 53, 472, 54, 415, 121, 566, 84, 484, 965, 669, 588, 145, 605, 233, 767, 245, 505, 511, 97, 768, 0},
{98, 804, 137, 94, 11, 3, 292, 796, 841, 248, 334, 444, 55, 171, 146, 320, 605, 975, 515, 707, 12, 853, 984, 489, 499, 0},
{989, 898, 639, 931, 880, 792, 815, 651, 577, 674, 250, 336, 961, 52, 766, 275, 936, 291, 365, 983, 145, 91, 82, 735, 448, 0},
{641, 531, 644, 391, 757, 246, 468, 296, 243, 23, 106, 301, 513, 962, 457, 520, 794, 126, 498, 897, 632, 292, 571, 750, 433, 0},
{724, 210, 267, 154, 2, 546, 817, 905, 484, 240, 262, 819, 908, 821, 76, 783, 688, 719, 30, 661, 622, 424, 330, 909, 111, 0},
{352, 966, 232, 839, 464, 997, 608, 895, 606, 681, 37, 848, 143, 889, 125, 290, 397, 677, 723, 843, 702, 534, 953, 70, 762, 0},
{945, 574, 542, 737, 812, 301, 528, 359, 691, 651, 581, 233, 67, 21, 891, 302, 572, 303, 788, 40, 582, 546, 478, 553, 19, 0},
{873, 395, 608, 714, 410, 819, 661, 163, 725, 520, 71, 714, 806, 795, 381, 157, 491, 100, 239, 545, 58, 978, 657, 480, 189, 0},
{778, 232, 813, 678, 181, 400, 97, 990, 719, 587, 554, 568, 293, 282, 480, 568, 718, 343, 502, 821, 236, 414, 156, 55, 884, 0},
{92, 94, 887, 656, 962, 896, 386, 129, 526, 280, 588, 849, 133, 192, 768, 975, 725, 88, 209, 828, 237, 846, 466, 407, 978, 0},
{988, 636, 156, 660, 601, 365, 724, 406, 795, 737, 954, 858, 982, 405, 339, 816, 440, 768, 650, 893, 720, 233, 799, 382, 494, 0},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }};
/*
第26列答案是:989,966,972,931,977,997,948,990,935,821,997,858,982,988,932,975,936,995,978,989,928,978,984,911,978,
第26行答案是:81,5,3,47,3,28,25,44,16,67,47,4,104,11,53,3,52,23,2,37,19,58,55,88,156,
*/
getMax(&A[0][1], &A[25][1]);
printf("Maximun value of 2nd colume is %f\n", A[25][1]);
getMin(&A[3][0], &A[3][25]);
printf("Minimun value of 4th row is %f\n", A[3][25]);
system("pause");
return 0;
}
void getMax(double *ptr, double *max)
{
int i;
*max = 0;
for (i=0;i<25;i++)
{
if (*max < *ptr)
*max = *ptr;
ptr += 26;
}
}
void getMin(double *ptr, double *min)
{
int i;
*min = 10000;
for (i=0;i<25;i++)
{
if (*min > *ptr++)
*min = *ptr;
}
}
作業八題目回到首頁