Advertisement
Guest User

Max

a guest
May 30th, 2015
283
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.39 KB | None | 0 0
  1. #include<iostream>
  2. using namespace std;
  3. int max (int x[]);
  4.  
  5. int main()
  6. {
  7.     int arr[4] = {3,3,2,2};    
  8.     int x= max(arr);
  9.     cout<<x<<endl;
  10.    
  11.    
  12.  system("pause");
  13.  return 0;  
  14. }
  15.  
  16. int max (int temp[])
  17. {
  18.     int max=temp[1];
  19.    
  20.     for(int i=1;i<temp[0];i++)
  21.     {
  22.             if(max<temp[i+1])
  23.             max=temp[i+1];
  24.     }
  25.    
  26.     return max;
  27.    
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement