Find The Third Max 或第三大数

问题描述 投票:0回答:0

如何修改以获得第三个最大值 如何修改以获得第三个最大值how to modify to get the third max 如何修改以获得第三个最大值

#include <iostream>
using namespace std;
int main() {
    int n,x;
    cout<< "\n enter size of array: ";
    cin>>n;
    int arr[n];
    cout<<"elements of the array: \n";
    for(int i=0;i<n;i++)
    cin>>arr[i];
    for(int i=0;i<n;i++){
        for (int j=i+i;  j<n; j++){
            if(arr[i]<arr[j]){
                x = arr[i];
                arr[i]=arr[j];
                arr[j] = x;
            }
        }
    }
    cout<<"third largest number is: "<<arr[1];
    cout<<endl;
    return 0;
 }````

how to modify to get the third max
how to modify to get the third maxhow to modify to get the third max
how to modify to get the third max
c++ max heap
© www.soinside.com 2019 - 2024. All rights reserved.