Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: Enter 10 numbers into an array and find the 3rd largest from it. #4146

Open
sudip1234567 opened this issue Oct 14, 2022 · 30 comments
Open

Comments

@sudip1234567
Copy link

Is your feature request related to a problem? Please describe.

Describe the solution you'd like

Describe alternatives you've considered

Additional context

@ayushigeorge
Copy link

hi, please assign it to me!

@ghost
Copy link

ghost commented Oct 15, 2022

Assign me this one please

@arpanghosh2416
Copy link

Can I get this assignment, please?

@axis1410
Copy link

I would love to do this task!

@sanahmathur
Copy link

hello @sudip1234567 sir, I would like to help in this issue.

@pratyushkr11
Copy link

Hello @sudip1234567 I would like to work on this issue. Can u assign me this.

@PRIYANSHUKUMAR22
Copy link

Hi, please assign it to me!

@royanurag005
Copy link

royanurag005 commented Oct 17, 2022

This could be considered as the solution to the problem and **I hope you like **

I hope #4146 issue is fixed.
`#include
using namespace std;
int main(){
int mat[10];
for(int i=0;i<10;i++){
cout<<"Enter the "<<i+1<<" element to your array:"<<endl;
cin>>mat[i];

}
for(int i=0;i<=9;i++){//using bubble sort algorithm
    for(int j=i;j<=9;j++){
        if(mat[j]<=mat[i]){
            int temp;
            temp=mat[i];
            mat[i]=mat[j];//bubble sort
            mat[j]=temp;
        }
    }
}
for(int i=0;i<10;i++){
    cout<<mat[i]<<"\t";
    
}
cout<<endl;
cout<<"The 3rd highest value is :"<<mat[7]<<endl;

}`

@yashg019
Copy link

hi,please assign it to me

@Rohit321-bit
Copy link

Please assign me this.I would love to do this task!

@PRIYANSHUKUMAR22
Copy link

#include <bits/stdc++.h>
void thirdLargest(int arr[ ], int arr_size)
if(arr_size<3){
printf("Invalid Input");
return;
}

int first = arr[0];
for(int i = 1; i<arr_size; i++)
if (arr[i]>first)
First = arr[i];
int second INT_MIN;
for(int i = 0; i<arr_size; i++)
if(arr[i]>third && arr[i]<second)
third = arr[i];
printf("the third largest element is %d\n, third);
}

int main( )
{
int arr[ ] = {12, 13, 1, 10, 34, 16};
int n = sizeof(arr) / sizrof(arr[0]);
thirdLargest(arr, n);
return 0 ;

@codeleaner001
Copy link

Hello please assign this to me.

@Codeprime-21
Copy link

assign it to me yaar...what a drag! I'll do it off na..😉😜

@mohitpal88
Copy link

can u assign this to me

@Natashaj02
Copy link

Hi sir! I would like to work on this issue, please do assign it to me.

@jarvisavinash
Copy link

Can you please assign this issue to me ?

@Mudita-M2
Copy link

please assign it to me

@MrAnnonymous001
Copy link

Hello,
Assign This Task To Me I Would Like To do This

@DharshanAnbalagan
Copy link

Please assign this issue to me @sudip1234567

@prabhat108
Copy link

HEY PLEASE ASSIGN IT TO ME

@Sanskrutiii
Copy link

Hello sir, can you assign this issue to me?

@Jyotigarg1407
Copy link

please assign it to me.

@Pranjal2140
Copy link

Please assign it to me

@AnishSingh5665
Copy link

Please Assign it to me.

@Jyoticharan
Copy link

please assign me this issue

@DevThazin
Copy link

I would like to work on this issue sir

@suryavema
Copy link

i would like to work on this and these are my ways in which to solve this problem

  1. we can use sord and get directly the answer
    numbers = [45, 12, 67, 32, 78, 56, 89, 23, 99, 10]

numbers.sort(reverse=True)

third_largest = numbers[2]

print("The 3rd largest number is:", third_largest)

  1. by using heapq.nlargest
    import heapq

numbers = [45, 12, 67, 32, 78, 56, 89, 23, 99, 10]
third_largest = heapq.nlargest(3, numbers)[-1]
print("The 3rd largest number is:", third_largest)

  1. by using loops

numbers = [45, 12, 67, 32, 78, 56, 89, 23, 99, 10]

first_largest = second_largest = third_largest = float("-inf")

for num in numbers:
if num > first_largest:
third_largest = second_largest
second_largest = first_largest
first_largest = num
elif num > second_largest:
third_largest = second_largest
second_largest = num
elif num > third_largest:
third_largest = num

print("The 3rd largest number is:", third_largest)

all are valid and efficient methods to find the 3rd largest number, and they avoid the full sorting of the array if that is a concern.

@anshul-132002
Copy link

Please assign me this issue.

@prabhat108
Copy link

I hope #4146 issue is fixed.
`#include
using namespace std;
int main(){
int mat[10];
for(int i=0;i<10;i++){
cout<<"Enter the "<<i+1<<" element to your array:"<<endl;
cin>>mat[i];

}
for(int i=0;i<=9;i++){//using bubble sort algorithm
for(int j=i;j<=9;j++){
if(mat[j]<=mat[i]){
int temp;
temp=mat[i];
mat[i]=mat[j];//bubble sort
mat[j]=temp;
}
}
}
for(int i=0;i<10;i++){
cout<<mat[i]<<"\t";

}
cout<<endl;
cout<<"The 3rd highest value is :"<<mat[7]<<endl;
}`

@Coding-whiz
Copy link

please assign me this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests