使用二进制搜索找出String数组中的数字索引 [英] Find out the index of number in the String array using binary search

查看:105
本文介绍了使用二进制搜索找出String数组中的数字索引的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

实际上我知道如何找到作为int数组的indexof({1,3,5,7,9},3),但我对如何找到indexof({1,3,我有点困惑, 5,7,9},3这是字符串数组

i希望通过使用二进制搜索来做到这一点我需要指导谢谢。

actually i know how to find indexof ({1,3,5,7,9},3) that is int array but i am little bit confused about how to find indexof ({"1","3","5","7","9"},"3") that is string array
i want to do this by using binary search i need guidelines thank you.

推荐答案

他们都是一样的。只是他们的数据类型不同。转一圈就是将字符串值转换为运行时的整数值。喜欢这个



They are both a like. Just their data types are different. One turn around would be, to conver the string values to integer values on the run time. Like this

Convert.ToInt16(element);





..然后在其上运行相同的过程。



.. and then run the same process on it.


这篇关于使用二进制搜索找出String数组中的数字索引的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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