找到第一个比另一个更大的数字 [英] find first number that have great increasing than another

查看:95
本文介绍了找到第一个比另一个更大的数字的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一系列数字。在其中一些之后,进展很大,之后的数字开始迅速增加。我怎样才能找到这个具体号码?例如:我们有2,4,7,8,6,19,26,38,50和2到6的进展很小但是从19开始进展很大,答案是19。

如何在C或C#中找到这个数字?

解决方案

你应该定义一个边距,比如数字之间的差异。

所以我要说保证金为2.

写一个for循环:

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());

休息;

}

希望能帮到你:)

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#?

解决方案

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 :)


这篇关于找到第一个比另一个更大的数字的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆