<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, 評(píng)論 - 24, 引用 - 0
    數(shù)據(jù)加載中……

    數(shù)據(jù)結(jié)構(gòu)(JAVA語(yǔ)言版)源代碼(數(shù)組部分)

    /*1.運(yùn)用一維數(shù)組設(shè)計(jì)一個(gè)可計(jì)算多個(gè)數(shù)的平均的程序*/
    ?
    //?public static int i=0;//for循環(huán)計(jì)數(shù)變量
    //?public static float Number[] = new float[20];//存儲(chǔ)數(shù)據(jù)的浮點(diǎn)數(shù)數(shù)組
    //?public static float Summary;//數(shù)據(jù)總和變量
    //?public static float Average;//數(shù)據(jù)平均變量
    ?
    //?public static void main(String[] args) {
    //?? TODO Auto-generated method stub
    //??System.out.println("HELLO JAVA...");
    //??Summary = 0;//數(shù)據(jù)總和變量初值化
    //??System.out.println("Please input the number of data:");//讀入最大可輸入數(shù)據(jù)個(gè)數(shù)
    //??ConsoleReader console = new ConsoleReader(System.in);
    //??int Max = console.readInt();
    //??System.out.println("");
    //??
    //??if(Max <= 20){//決定最大可輸入數(shù)
    //???for(i=0;i<Max;i++){
    //????System.out.println("Please input a number:");
    //????Number[i] = (float)console.readDouble();
    //????Summary += Number[i];
    //???}
    //???Average = Summary/Max;//平均值=總和/個(gè)數(shù)
    //???System.out.println("The average is:"+Average);
    //??}else{//如果輸入數(shù)字超出范圍
    //???System.out.println("Please input a number less than 20.");
    //??}
    //?}
    ?/*2.運(yùn)用一維數(shù)組設(shè)計(jì)一個(gè)簡(jiǎn)易的員工工資管理系統(tǒng)(具有查詢與修改功能)*/
    ?/*
    ? * public static int[] Employee={27000,27111,27222,27333,27444,27555,27666,27777,27888,27999};
    ?public static int Index;//數(shù)組下標(biāo)變量
    ?public static int NewSalary;//修改後工資變量
    ?public static int Selection;//用戶選項(xiàng)變量
    ?
    ? 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:");//讀取用戶選項(xiàng)
    ???ConsoleReader console = new ConsoleReader(System.in);
    ???int Selection = console.readInt();
    ???if(Selection ==1 || Selection ==2){
    ????System.out.println("Please input the employee number:");//讀取員工編號(hào)
    ????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.運(yùn)用一維數(shù)組設(shè)計(jì)一個(gè)可存儲(chǔ)員工工資讓用戶輸入工資,然後輸出員工編號(hào)的程序*/
    ?/*
    ? public static int[] Employee={27000,27111,27222,27333,27444,27555,27666,27777,27888,27999};//預(yù)設(shè)10筆資料
    ?public static int Salary;//用戶輸入工資變量
    ?public static int Counter=0;//數(shù)據(jù)計(jì)數(shù)變量
    ? int i;//for循環(huán)計(jì)數(shù)變量
    ??System.out.println("Please input the employee salary:");
    ??ConsoleReader console = new ConsoleReader(System.in);
    ??Salary = console.readInt();
    ??for(i=0;i<10;i++){//數(shù)組遍歷
    ???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.設(shè)計(jì)一個(gè)可容納40位數(shù)的求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("");
    ??}
    ? */
    ?/*設(shè)計(jì)從二維轉(zhuǎn)一維數(shù)組(行轉(zhuǎn)列或列轉(zhuǎn)行)*/
    ?/*
    ? int[][] Data = {{1,2,3},{4,5,6},{7,8,9},{0,10,11}};
    ??int RowData[] = new int[12];//存儲(chǔ)以行為主的數(shù)組
    ??int ColData[] = new int[12];//存儲(chǔ)以列為主的數(shù)組
    ??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("");
    ? */
    ?/*特殊的數(shù)組(稀疏數(shù)組)*/
    ?/*
    ? *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];//存儲(chǔ)壓縮後數(shù)據(jù)的數(shù)組
    ??int Index;//壓縮數(shù)組的下標(biāo)
    ??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++;//增加下標(biāo)值
    ?????CompressData [Index][0] = i;//元素行位置
    ?????CompressData [Index][1] = j;//元素列位置
    ?????CompressData [Index][2] = Data[i][j];//元素值
    ????}
    ???}
    ??}
    ??CompressData [0][0] = 9;//原數(shù)組的行數(shù)
    ??CompressData [0][1] = 7;//原數(shù)組的列數(shù)
    ??CompressData [0][2] = Index;//使用元素個(gè)數(shù)
    ??
    ??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 閱讀(2099) 評(píng)論(3)  編輯  收藏

    評(píng)論

    # re: 數(shù)據(jù)結(jié)構(gòu)(JAVA語(yǔ)言版)源代碼(數(shù)組部分)  回復(fù)  更多評(píng)論   

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

    # re: 數(shù)據(jù)結(jié)構(gòu)(JAVA語(yǔ)言版)源代碼(數(shù)組部分)  回復(fù)  更多評(píng)論   

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

    # re: 數(shù)據(jù)結(jié)構(gòu)(JAVA語(yǔ)言版)源代碼(數(shù)組部分)  回復(fù)  更多評(píng)論   

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

    只有注冊(cè)用戶登錄后才能發(fā)表評(píng)論。


    網(wǎng)站導(dǎo)航:
     
    主站蜘蛛池模板: 亚洲av无码不卡久久| 免费精品视频在线| 国产一级特黄高清免费大片| 国产精品黄页免费高清在线观看| 亚洲精品国偷自产在线| 4hu四虎最新免费地址| 美女尿口扒开图片免费| 亚洲va在线va天堂va四虎| 成人永久福利免费观看| 久久国产精品成人免费| 亚洲高清视频在线| 亚洲色成人网站WWW永久| 国产美女在线精品免费观看| 九九免费精品视频在这里| 亚洲国产高清在线精品一区 | 久久99国产乱子伦精品免费| 亚洲国产成人久久一区二区三区| 中文字幕久久亚洲一区| 最近高清国语中文在线观看免费 | 国产在线观看免费观看不卡| 国产亚洲欧美日韩亚洲中文色| 国产A在亚洲线播放| 永久免费毛片手机版在线看| 午夜精品一区二区三区免费视频| 麻豆亚洲AV成人无码久久精品 | 性色av极品无码专区亚洲| aa级毛片毛片免费观看久| 亚洲ts人妖网站| 国产亚洲精久久久久久无码| 日韩高清在线高清免费| 91成人在线免费视频| 国产日韩精品无码区免费专区国产 | 中文永久免费观看网站| 亚洲人成自拍网站在线观看| 亚洲人成亚洲精品| 国产亚洲精品不卡在线| 日本一道综合久久aⅴ免费| 中文字幕无码播放免费| 国产精品白浆在线观看免费 | 日韩一区二区a片免费观看 | 免费一级特黄特色大片在线观看 |