c#找到组相关的数字 [英] c# find number to group correlation

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

问题描述

我有可以更改的数字范围,例如

i have ranges of numbers that can change, for example

第1组:1> 10000

group 1: 1->10000

第2组: 10001-> 25000等等....

group 2: 10001->25000 and so on....

我得到一个号码23212

I get a number 23212

我想知道它属于第2组

最好的方法是什么?

推荐答案

如果你有一个范围列表你的小组,你可以使用WHILE语句在你的列表末尾向下移动,询问你的数字是否在这样的实际范围之间。

If you have a list of range for your groups, you can use a WHILE statement to move down at end of your list asking for if you number is between the actual range somethin like this.

- Estructura lista de rango

--Estructura lista de rango

struct rango {

struct rango {

  id_group int;

 id_group int;

  init_val int;

 init_val int;

end_val int;

end_val int;

};

列表< rango> MyRanges()= new List()....

List<rango> MyRanges() = new List()....

int number = 23212;

int number = 23212;

int grupo = 0;

int grupo =0;

  while(grupo == 0&& MyRanges!= end){

 while(grupo==0 && MyRanges!=end) {

  if(number> = MyRanges.init_val&& number< = MyRanges.end_val)

  if(number>=MyRanges.init_val && number<=MyRanges.end_val)

   {

   {

     grupo = MyRanges.Index;

     grupo = MyRanges.Index;

   }

   }

}

类似的东西,当然有些语法不好。我希望可以帮到你。

Something like that, of course some syntax is not good. I hope can help you.


这篇关于c#找到组相关的数字的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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