-
[알고리즘] 07년 fall 중간고사 2번문제정리필요2 2007. 10. 12. 17:39
#include <stdio.h>
int max(int b, int s){
if( b >= s )
return b;
else
return s;
}
int Max(int low, int high, int data[])
{
int mid = (int)((low + high)/2);if((high - low) <= 1){
return max(data[low], data[high]);
}
else{
return max(Max(low, mid, data), Max(mid+1, high, data));
}
}int main()
{
int maximum, maximum1;
int Data[11] = {0, 1, 2, 3, 4, 8, 6, 13, 3, 7, 6};
int Data1[10] = {0, 1, 2, 3, 4, 12, 4, 3, 7, 6};maximum = Max(1, 10, Data);
maximum1 = Max(1, 9, Data1);printf("%d\t", maximum);
printf("%d\t", maximum1);
return 0;
}