fork download
  1. #include <bits/stdc++.h>
  2. #include <iostream>
  3. #include <string>
  4. #include <vector>
  5. #include <utility>
  6. using namespace std;
  7. #define saleh ios_base::sync_with_stdio(false);cin.tie(nullptr)
  8. #define endl "\n"
  9.  
  10.  
  11. int mx;
  12. void solve(int index , int arr[] , int sizee){
  13. if(index == sizee){
  14. return;
  15. }
  16. else {
  17. mx = max(mx , arr[index]);
  18. solve(index+1 , arr , sizee);
  19.  
  20. }
  21. }
  22.  
  23.  
  24. int main() {
  25. cout<<"Enter the number of elemens"<<endl;
  26. int n;cin>>n;
  27. int arr[n];
  28. cout<<"Enter the elemens"<<endl;
  29. for(int i =0;i<n;i++)cin>>arr[i];
  30.  
  31. mx = arr[0];
  32. solve( 0 , arr , n );
  33. cout<<mx;
  34.  
  35.  
  36.  
  37. return 0;
  38. }
Success #stdin #stdout 0.01s 5252KB
stdin
Standard input is empty
stdout
Enter the number of elemens
Enter the elemens
2147479976