P to P

          何以解憂,唯有學習!讓每一個人都能Open Source
          posts - 4, comments - 12, trackbacks - 0, articles - 11

          public class ArrayApp {
          ???
          ??? public static void main(String[] args) {
          ??? ?long[] arr;
          ??? ?arr=new long[100];
          ??? ?long searchKey;
          ??? ?int i;
          ??? ?arr[0]=12;
          ??? ?arr[1]=3;
          ??? ?arr[2]=15;
          ??? ?arr[3]=72;
          ??? ?arr[4]=32;
          ??? ?arr[5]=452;
          ??? ?arr[6]=332;
          ??? ?arr[7]=752;
          ??? ?arr[8]=3542;
          ??? ?arr[9]=1322;
          ??? ?int nElements=10;
          ??? ?
          ??? ?/***************************display********************************/
          ??? ?for (i=0;i<nElements;i++)
          ??? ??System.out.print(arr[i]+" ");
          ??? ?System.out.println(" ");
          ??? ?
          ??? ?
          ??? ?/***************************search********************************/
          ??? ?searchKey=20;
          ??? ?for (i=0;i<nElements;i++)
          ??? ??if (arr[i]==searchKey)
          ??? ???break;
          ??? ???
          ??? ?if (i==nElements)
          ??? ??System.out.println("找不到"+searchKey);
          ??? ?else
          ??? ??System.out.println("找到了"+searchKey+"在"+i+"上");
          ??? ?
          ??? ?/***************************delete********************************/?
          ??? ?searchKey=135456;
          ??? ?for (i=0;i<nElements;i++)
          ??? ??if (arr[i]==searchKey)
          ??? ??{
          ??? ???System.out.println("找到數"+searchKey+ " 并刪除之");?
          ??? ???for(int k=i;k<nElements-i;k++)
          ??? ????arr[k]=arr[k+1];
          ??? ???nElements--;
          ??? ??}?
          ??? ?/***************************display********************************/
          ??? ?for (i=0;i<nElements;i++)
          ??? ??System.out.print(arr[i]+" ");
          ??? ?System.out.println(" ");
          ??? ?
          ??? ?
          ??? ?
          ???????
          ??? }

          主站蜘蛛池模板: 永昌县| 呼图壁县| 八宿县| 巴彦淖尔市| 巴东县| 吴川市| 辛集市| 图们市| 信宜市| 耒阳市| 安顺市| 扶绥县| 柳州市| 阿克苏市| 亳州市| 阿尔山市| 巨野县| 淮北市| 婺源县| 微山县| 翼城县| 彰化市| 紫阳县| 云安县| 河津市| 两当县| 夏邑县| 离岛区| 永城市| 游戏| 密山市| 衡南县| 彭阳县| 武义县| 鄢陵县| 潮州市| 桂林市| 阳山县| 昭平县| 普宁市| 兰考县|