2012年11月17日

       总想提笔写点什么,却不知道该怎样记录这几个月的生活。满脑的思绪却无从下笔,只是感觉找工作也不是自己想的那么容易。看着一起找工作的人都找到了,就自己没有找到合适的,就慢慢的开始怀疑自己,对生活和未来丧失信心。不过还好懂得,人最不能放弃的就是希望,好多事情尽了自己最大的努力就好。
      
posted @ 2012-11-17 09:04 skylight 阅读(149) | 评论 (0)编辑 收藏
 1package com.test2;
 2
 3public class Demo2 {
 4
 5    /**
 6     * @param args
 7     */

 8
 9    public static int search(int[] arrays, int target) {
10
11        int start = 0;
12        int end = arrays.length - 1;
13        int pos;
14        while (start <= end) {
15            pos = (start + end) / 2;
16            if (arrays[pos] == target) {
17                return pos;
18            }
 else if (arrays[pos] > target) {// 如果数组中间的数大于目标,则将end的位置变成数组中间位置-1的位置
19                end = pos - 1;
20            }
 else {
21                start = pos + 1;// 如果数组中间的数小于目标,则将start的位置变成数组中间位置+1的位置
22            }

23        }

24        return -1// 若没有查找到,则返回-1
25    }

26
27    public static void main(String[] args) {
28        int[] arrays = 232839592883223242323 };
29        System.out.println(search(arrays, 28));
30        System.out.println(search(arrays, 322));
31        System.out.println(search(arrays, 59));
32        System.out.println(search(arrays, 288));
33    }

34
35}

36
posted @ 2012-11-17 08:30 skylight 阅读(164) | 评论 (0)编辑 收藏

导航

<2012年11月>
28293031123
45678910
11121314151617
18192021222324
2526272829301
2345678

统计

常用链接

留言簿

随笔分类

随笔档案

搜索

最新评论

阅读排行榜

评论排行榜