fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. const long long MOD=1e9+7;
  4. int Lonthunhi(vector<int> &a) {
  5. int n=a.size();
  6. sort(a.begin(),a.end());
  7. for (int i=n-2;i>=0;i--) {
  8. if (a[i]!=a[n-1]) {
  9. return a[i]; // Dừng code lại!
  10. }
  11. }
  12. // Nếu ko có số nào tm trả về -1!
  13. return -1;
  14. }
  15.  
  16. int main() {
  17. vector<int> a = {36,67,69};
  18. cout<<Lonthunhi(a);
  19. return 0;
  20. }
Success #stdin #stdout 0.01s 5328KB
stdin
Standard input is empty
stdout
67