Click here to Skip to main content
15,891,908 members

Comments by verma.9878528979 (Top 7 by date)

verma.9878528979 11-Jan-13 0:14am View    
tags is not my problem ,the logic is.I want to make it my self but can't get the logic how to do it. all i need is an idea so i can make it.c++ always helps!!!!
verma.9878528979 11-Jan-13 0:04am View    
there a random values for example salary of 30 employee, the data in the salary will be in any order and i think shorting will not wrk in this condition. i have to find random highest values it can be 2nd or 3rd or 5th etc i have created an program in c#.net where output shows in lable but it only shows the 2nd largest
{
int[] arr = { 10, 25, 45, 12, 30, 85, 14, 75, 89 };


int temp, f, s, t;
f = s = t = arr[0];
foreach (int i in arr)
{
if (f < i)
{
temp = f;
f = i;
t = temp;

}
if (s < i && f > i)
{
temp = i;
s = i;
t = temp;
}
if (t < i && s > i)
{
temp = i;
t = i;
}
}

Label1.Text = t.ToString();
}
i want to give input for nth term like i want to see 5th largest or the 3rd largest.
verma.9878528979 10-Jan-13 23:57pm View    
the values will not be arranged so i don't think shorting works here..
verma.9878528979 10-Jan-13 23:56pm View    
All i need is a simple example in c++ so i can understand the logic behind the program.
verma.9878528979 10-Jan-13 23:53pm View    
guys. all i wana know the logic behind the loop to find nth term i have created a simple program in ASP.net. which shows the 2nd largest from an array but i want to input multipal values and then any nth term..n yes let me tel you one thing it's not homework i need it for a project. here what i have done :
{
int[] arr = { 10, 25, 45, 12, 30, 85, 14, 75, 89 };


int temp, f, s, t;
f = s = t = arr[0];
foreach (int i in arr)
{
if (f < i)
{
temp = f;
f = i;
t = temp;

}
if (s < i && f > i)
{
temp = i;
s = i;
t = temp;
}
if (t < i && s > i)
{
temp = i;
t = i;
}
}

Label1.Text = t.ToString();
}
now this program finds the 2nd largest but i need to give random input for the nth largest term. it can be 2nd , 3rd, 5th or even 8th largest value... help!!!