⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 testdoublearray.java

📁 还不错的java基本实例
💻 JAVA
字号:
/*
 * 创建日期 2006-1-28
 *
 * TODO 要更改此生成的文件的模板,请转至
 * 窗口 - 首选项 - Java - 代码样式 - 代码模板
 */
package ch4;
import javax.swing.JOptionPane;
public class TestdoubleArray {
    static String output="";
    static int minimum(int[][]  Score){	
	    int lowscore  = 100;
        int i, j ;
        for (i = 0 ;i< Score.length;i++)
            for(j = 0 ;j< Score[i].length;j++)
                if (Score[i][j] < lowscore) 
                    lowscore = Score[i][j];       
        return lowscore;
    }
    
    static int maximum(int[][]  Score){	
	    int highscore  = 0;
        int i, j ;
        for (i = 0 ;i< Score.length;i++)
            for(j = 0 ;j< Score[i].length;j++)
                if (Score[i][j] > highscore) 
                    highscore = Score[i][j];       
        return highscore;
    }
    
    static double average(int[][]s,int k){	
       double total = 0;
        for(int i = 0 ;i<s[i].length;i++)
            total += s[k][i];
        return (double)(total / s[0].length);
    }
    
    static void buildstring(int[][]  Score){	
            output += "       ";
            for(int i = 0; i< Score[i].length;i++)
                output += "    考试" +i ;
 
            for( int m = 0;m<Score.length;m++){
                output += "\n" + "学生" + m +"     ";
                for (int j = 0;j< Score[m].length;j++)
                    output += Score[m][j] + "         ";
            }
    }
    
    
    public static void main(String[] args){	
    int[][] Score  = {{99, 80}, {80, 76}, {96, 80}, {89, 90}, {98, 87}};
    output = "数组是:" +"\n";
    buildstring(Score);
    output += "\n\n" + "最低分:" + minimum(Score) +"\n"+ "最高分:" + maximum(Score)+"\n";
    for(int i = 0;i< Score.length;i++)
        output += "\n"+ "学生" + i + "的平均成绩为:" + average(Score, i);
    JOptionPane.showMessageDialog(null,output);
    }   
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -