<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    Sunspl

    Hello,everyone,i am sun. 天道酬勤,笨鳥先飛.
    隨筆 - 47, 文章 - 0, 評論 - 24, 引用 - 0
    數據加載中……

    數據結構(JAVA語言版)源代碼(數組部分)

    /*1.運用一維數組設計一個可計算多個數的平均的程序*/
    ?
    //?public static int i=0;//for循環計數變量
    //?public static float Number[] = new float[20];//存儲數據的浮點數數組
    //?public static float Summary;//數據總和變量
    //?public static float Average;//數據平均變量
    ?
    //?public static void main(String[] args) {
    //?? TODO Auto-generated method stub
    //??System.out.println("HELLO JAVA...");
    //??Summary = 0;//數據總和變量初值化
    //??System.out.println("Please input the number of data:");//讀入最大可輸入數據個數
    //??ConsoleReader console = new ConsoleReader(System.in);
    //??int Max = console.readInt();
    //??System.out.println("");
    //??
    //??if(Max <= 20){//決定最大可輸入數
    //???for(i=0;i<Max;i++){
    //????System.out.println("Please input a number:");
    //????Number[i] = (float)console.readDouble();
    //????Summary += Number[i];
    //???}
    //???Average = Summary/Max;//平均值=總和/個數
    //???System.out.println("The average is:"+Average);
    //??}else{//如果輸入數字超出范圍
    //???System.out.println("Please input a number less than 20.");
    //??}
    //?}
    ?/*2.運用一維數組設計一個簡易的員工工資管理系統(具有查詢與修改功能)*/
    ?/*
    ? * public static int[] Employee={27000,27111,27222,27333,27444,27555,27666,27777,27888,27999};
    ?public static int Index;//數組下標變量
    ?public static int NewSalary;//修改後工資變量
    ?public static int Selection;//用戶選項變量
    ?
    ? boolean Flag = false;
    ??while(!Flag){
    ???//用戶菜單
    ???System.out.println("++++++++++++++++++++++++++++++++++++++");
    ???System.out.println("1.Display employee salary =");
    ???System.out.println("2.Modify employee salary =");
    ???System.out.println("3.Quit");
    ???System.out.println("++++++++++++++++++++++++++++++++++++++");
    ???System.out.println("Please input your choose:");//讀取用戶選項
    ???ConsoleReader console = new ConsoleReader(System.in);
    ???int Selection = console.readInt();
    ???if(Selection ==1 || Selection ==2){
    ????System.out.println("Please input the employee number:");//讀取員工編號
    ????Index = console.readInt();
    ????if(Index <10){
    ?????System.out.println("**Employee Number is"+Index);
    ?????System.out.println("**The Salary is"+Employee[Index]);
    ????}else{
    ?????System.out.println("##The error employee number!");
    ?????Flag = true;
    ????}
    ???}
    ???switch(Selection){
    ???case 1:
    ????break;
    ???case 2:
    ????System.out.println("**Please enter new Salary:");//修改後的員工工資
    ????NewSalary = console.readInt();
    ????System.out.println("");
    ????Employee[Index]=NewSalary;
    ????break;
    ???case 3:
    ????Flag = true;
    ????System.out.println("You leave from System.");
    ????break;
    ???}
    ???System.out.println("");
    ??}
    ? */
    ?/*3.運用一維數組設計一個可存儲員工工資讓用戶輸入工資,然後輸出員工編號的程序*/
    ?/*
    ? public static int[] Employee={27000,27111,27222,27333,27444,27555,27666,27777,27888,27999};//預設10筆資料
    ?public static int Salary;//用戶輸入工資變量
    ?public static int Counter=0;//數據計數變量
    ? int i;//for循環計數變量
    ??System.out.println("Please input the employee salary:");
    ??ConsoleReader console = new ConsoleReader(System.in);
    ??Salary = console.readInt();
    ??for(i=0;i<10;i++){//數組遍歷
    ???if(Salary == Employee[i]){
    ????System.out.println("Number"+i+"Employee's salary is"+Salary+"!");
    ????Counter++;
    ???}
    ??}
    ???if(Counter == 0){
    ????System.out.println("No employee's salary is"+Salary+"!!");
    ???}else{
    ????System.out.println("Have"+Counter+"employee salary is"+Salary+"!!");
    ???}
    ? */
    ?/*4.設計一個可容納40位數的求n!的程序*/
    ?/*
    ? int Data[] = new int[40];
    ??int Digit;
    ??int i,j,r,k;
    ??int N;
    ??for(i=1;i<40;i++){
    ???Data[i]=0;
    ??}
    ??Data[0]=1;
    ??Data[1]=1;
    ??Digit = 1;
    ??System.out.println("Enter a number what you want to calculus:");
    ??ConsoleReader console = new ConsoleReader(System.in);
    ??N = console.readInt();
    ??for(i=1;i<N+1;i++){
    ???for(j=1;j<Digit+1;j++){
    ????Data[j]*=i;
    ???}
    ???for(j=1;j<Digit+1;j++){
    ????if(Data[j]>10){
    ?????for(r=1;r<Digit+1;r++){
    ??????if(Data[Digit]>10){
    ???????Digit ++;
    ??????}
    ??????Data[r+1] += Data[r]/10;
    ??????Data[r]=Data[r]%10;
    ?????}
    ????}
    ???}
    ???System.out.print(i+"!=");
    ???for(k=Digit;k>0;k--){
    ????System.out.print(Data[k]);
    ???}
    ???System.out.println("");
    ??}
    ? */
    ?/*設計從二維轉一維數組(行轉列或列轉行)*/
    ?/*
    ? int[][] Data = {{1,2,3},{4,5,6},{7,8,9},{0,10,11}};
    ??int RowData[] = new int[12];//存儲以行為主的數組
    ??int ColData[] = new int[12];//存儲以列為主的數組
    ??int i,j;
    ??System.out.println("The Data of two dimensional array:");
    ??for(i=0;i<4;i++){
    ???for(j=0;j<3;j++){
    ????System.out.println(" "+Data[i][j]+" ");
    ????System.out.println("");
    ???}
    ??}
    ??for(i=0;i<4;i++){
    ???for(j=0;j<3;j++){
    ????RowData[i*3+j] = Data[i][j];
    ???}
    ??}
    ??System.out.println("");
    ??System.out.println("The Row major Martrix:");
    ??for(i=0;i<12;i++){
    ???System.out.println(" "+RowData[i]+" ");
    ??}
    ??System.out.println("");
    ??for(i=0;i<4;i++){
    ???for(j=0;j<3;j++){
    ????ColData[j*4+i] = Data[i][j];
    ???}
    ??}
    ??System.out.println("");
    ??System.out.println("The Column Major Matrix:");
    ??for(i=0;i<12;i++){
    ???System.out.println(" "+ColData[i]+" ");
    ??}
    ??System.out.println("");
    ? */
    ?/*特殊的數組(稀疏數組)*/
    ?/*
    ? *int [][] Data = {{0,0,0,0,0,0,0}
    ??????,{0,3,0,0,0,0,0}
    ??????,{0,0,0,0,0,0,0}
    ??????,{1,4,0,0,0,0,0}
    ??????,{0,0,7,0,0,0,0}
    ??????,{0,0,0,0,0,5,0}
    ??????,{0,0,0,0,0,0,0}
    ??????,{0,0,0,0,0,0,0}
    ??????,{0,0,0,0,0,0,0}
    ??????,{0,0,0,0,0,0,0}};
    ??int CompressData[][] = new int[10][3];//存儲壓縮後數據的數組
    ??int Index;//壓縮數組的下標
    ??int i,j;
    ??Index = 0;
    ??System.out.println("Two dimensional sparse array:");
    ??for(i=0;i<9;i++){
    ???for(j=0;j<7;j++){
    ????System.out.print(" "+Data[i][j]+" ");
    ???}
    ???System.out.println("");
    ??}
    ??for(i=0;i<9;i++){
    ???for(j=0;j<7;j++){
    ????if(Data[i][j] != 0){
    ?????Index++;//增加下標值
    ?????CompressData [Index][0] = i;//元素行位置
    ?????CompressData [Index][1] = j;//元素列位置
    ?????CompressData [Index][2] = Data[i][j];//元素值
    ????}
    ???}
    ??}
    ??CompressData [0][0] = 9;//原數組的行數
    ??CompressData [0][1] = 7;//原數組的列數
    ??CompressData [0][2] = Index;//使用元素個數
    ??
    ??System.out.println("Two dimensional compress array:");
    ??for(i=0;i<Index;i++){
    ???for(j=0;j<3;j++){
    ????System.out.print(" "+CompressData[i][j]+" ");
    ???}
    ???System.out.println("");
    ??}
    ? */

    posted on 2006-08-15 11:39 JavaSuns 閱讀(2098) 評論(3)  編輯  收藏

    評論

    # re: 數據結構(JAVA語言版)源代碼(數組部分)  回復  更多評論   

    字體顏色太不實用了,眼花
    2006-08-15 16:19 | GoKu

    # re: 數據結構(JAVA語言版)源代碼(數組部分)  回復  更多評論   

    @GoKu
    已修改過了
    2006-08-16 13:39 | sunspl

    # re: 數據結構(JAVA語言版)源代碼(數組部分)  回復  更多評論   

    欠扁啊,忽悠老子!
    2008-08-04 01:37 | gjrh

    只有注冊用戶登錄后才能發表評論。


    網站導航:
     
    主站蜘蛛池模板: 在线精品一卡乱码免费| 热99RE久久精品这里都是精品免费| 无码国产精品一区二区免费vr | a免费毛片在线播放| 亚洲av无码不卡私人影院| 国产亚洲精品仙踪林在线播放| 在线a毛片免费视频观看| 亚洲第一区二区快射影院| 无码国产精品久久一区免费| 国产精品亚洲精品观看不卡| 免费在线看v网址| 中文字幕亚洲综合久久综合| 成人免费视频试看120秒| 亚洲av乱码中文一区二区三区| 四虎永久成人免费影院域名| 色吊丝性永久免费看码 | 国产精品免费AV片在线观看| 久久精品国产亚洲av麻豆| 91免费在线播放| 久久亚洲国产最新网站| www亚洲一级视频com| 久久嫩草影院免费看夜色| 亚洲爆乳精品无码一区二区三区| 小草在线看片免费人成视久网| 亚洲精品第五页中文字幕| 久久受www免费人成_看片中文| 亚洲熟妇自偷自拍另欧美| 亚洲成?v人片天堂网无码| 最近中文字幕免费大全| 亚洲依依成人精品| 亚洲AV成人潮喷综合网| 国产一区二区免费| 亚洲色精品VR一区区三区| 亚洲精品无码专区久久同性男| 国产羞羞的视频在线观看免费| 亚洲午夜久久久久久尤物| va亚洲va日韩不卡在线观看| 久草免费手机视频| 亚洲国产美女精品久久久| 亚洲精品少妇30p| 最近的中文字幕大全免费版|