<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

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


    網站導航:
     
    主站蜘蛛池模板: 国产亚洲精品影视在线产品| 四虎成人免费网站在线| 亚洲精品乱码久久久久久自慰| 亚洲一二成人精品区| 亚洲AV区无码字幕中文色| 深夜福利在线视频免费| 九月婷婷亚洲综合在线| 四虎精品成人免费视频| 99re这里有免费视频精品 | 亚洲av日韩综合一区二区三区| 亚洲成年人在线观看| 97无码人妻福利免费公开在线视频 | 国产精品无码一二区免费| 亚洲精品无码MV在线观看| 99麻豆久久久国产精品免费| 亚洲美女又黄又爽在线观看| 在线观看免费无码专区| 亚洲综合图片小说区热久久| 久久久久国产精品免费免费搜索| 成人一a毛片免费视频| 亚洲高清毛片一区二区| 国产亚洲日韩在线a不卡| 亚洲成av人在片观看| 亚洲国产精品无码专区| 足恋玩丝袜脚视频免费网站| 我想看一级毛片免费的| 亚洲国产精品自在线一区二区 | 亚洲人片在线观看天堂无码| 99re视频精品全部免费| 亚洲欧洲精品成人久久奇米网| 亚洲成AV人片在线观看无码| 免费无码成人AV在线播放不卡| 久久乐国产精品亚洲综合| 日本亚洲中午字幕乱码| a级精品九九九大片免费看| 亚洲AV日韩AV永久无码久久| 四虎永久在线精品免费网址| 皇色在线免费视频| 亚洲成人福利在线观看| 亚洲国产综合人成综合网站| 最近免费中文字幕大全高清大全1 最近免费中文字幕mv在线电影 |