intfind_max(int arr[],int size){ int max = 0; for(int i = 0; i < size; i++){ if(max < arr[i]) max = arr[i]; } return max; } intmain(){ int arr[6] = {1,8,5,9,10,6}; int res = find_max(arr,6); std::cout<<"the max num = "<<res<<"\n"; return0; }
intfind_max(int arr[],int size){ int max = 0; for(int i = 0; i < size; i++){ if(max < arr[i]) max = arr[i]; } return max; } intmain(){ int arr[6] = {1,8,5,9,10,6}; int res_max = find_max(arr,6); std::cout<<"the max num = "<<res_max<<"\n"; int res_min = find_min(arr,6); std::cout<<"the min num = "<<res_min<<"\n"; return0; }
intfind_max(int arr[],int size){ int max = 0; for(int i = 0; i < size; i++){ if(max < arr[i]) max = arr[i]; } return max; } intmain(){ int arr[6] = {1,8,5,9,10,6}; int res_max = find_max(arr,6); std::cout<<"the max num = "<<res_max<<"\n"; int res_min = find_min(arr,6); std::cout<<"the min num = "<<res_min<<"\n"; find_arr(arr,6); return0; }
修改makefile
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
translater = g++ opt_c = -c opt_o = -o
main: main.cpp find_min.o find_arr.o $(translater) main.cpp find_min.o find_arr.o $(opt_o) main