Click here to Skip to main content
15,881,600 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I have array of numbers. After one number of these,the progress is big and numbers after that start to increase rapidly. How can I find this specific number? for example:we have 2,4,7,8,6,19,26,38,50 and from 2 to 6 the progress is small but from 19 the progress is big, the answer is 19.
How can I find this number in C or C#?
Posted
Comments
Sergey Alexandrovich Kryukov 17-Jan-13 20:17pm    
We won't do your homework for you, sorry. What have you done so far, what's the problem?

You wording sounds gibberish, by the way; listen to yourself: "progress is big", "start to increase rapidly" (aha, if no so rapidly, the algorithm is different, isn't it? :-). If you have no clue of elementary school mathematics, be advised that his is on of most basic prerequisites to programming. Whatever you ask, it should be formulated formally, not just by example.

Please don't tell us you are a beginner: we see it; this is not an excuse for not using your brain.

Good luck,
—SA
adriancs 17-Jan-13 21:53pm    
for rapid change, cache the last existed largest number.
for slow change, compare the values one by one, or
sort the values and get the 1st or last.

1 solution

Well you should define a margin, like say the diffence between numbers.
So lets say the margin is 2.
write a for loop:
int[] a=new int[100]
for (int i=0;i<100;i++)
{
current= read(input);
}
margin=5;
for (int i=0;i<100;i++)
{
if a[i]-a[i-1]>margin writeoutput(i.tostring());
break;
}
hope to helped you :)
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900