Tusohian

Find Max Number using Genetic Search

Aug 11th, 2017
343
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.43 KB | None | 0 0
  1. #include<iostream>
  2.  
  3. using namespace std;
  4.  
  5. template <class Data>
  6. Data Max(Data *x, int n){
  7.     int i;
  8.     Data max;
  9.     max = x[0];
  10.     for(i = 0; i < n; i++){
  11.         if(x[i] > max){
  12.             max = x[i];
  13.         }
  14.     }
  15.     return max;
  16. }
  17.  
  18. int main(){
  19.     int age[5] = {5, 9 , 4, 7, 3};
  20.     double cgpa[5] = {3.5, 1.9, 2.9, 3.9, 2.5};
  21.     int ans;
  22.     ans = Max(age, 5);
  23.     cout << ans << endl;
  24.     return 0;
  25. }
Add Comment
Please, Sign In to add comment