| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 2524 人关注过本帖, 1 人收藏
标题:学生成绩 怎么输出不来
取消只看楼主 加入收藏
X15810803158
Rank: 2
等 级:论坛游民
帖 子:49
专家分:36
注 册:2015-2-24
结帖率:91.67%
收藏(1)
已结贴  问题点数:5 回复次数:0 
学生成绩 怎么输出不来
import java.util.Scanner;
public class S{
    public static void main(String[] args){
        Scanner in = new Scanner (System.in);
        System.out.println("请输入学生的个数");
        int renshu = in.nextInt();//存储学生的个数
        System.out.println("请输入科目的数量");
        int course = in.nextInt();//存储科目的数量
        
        String[] name = new String[renshu];//声明一个数组来存储学生的个数
        String[] courseN = new String[course];
        int [][] number = new int[renshu][course];
        int [] sum = new int[renshu];
        int [] ave = new int[renshu];
        String[] str = new String[renshu];
        
        //循环存储科目的名称
        for (int i=0; i<courseN.length; i++){
            System.out.println("请输入"+(i+1)+"门科目");
            courseN[i] = in.next();
            
            }
        
        //用来录入学生各科成绩
        for (int i=0; i<renshu; i++){
            int S = 0;//声明一个S,表示总分
            String str123 = "";
            System.out.println("请输入学生的姓名");
            name[i] = in.next();
            for (int j=0; j<course; j++){
                System.out.println("请输入"+name[i]+courseN[j]+"的成绩");
                number[i][j] = in.nextInt();
                S+=number[i][j];
                str123 += number[i][j]+"\t";
                }
                sum[i] = S;//求此同学的总分存入总分数组
                ave[i] = S/course;
                str[i] = name[i]+"\t"+str123+"\t"+sum[i]+"\t"+ave[i];
               
            }
            
            for (int i=0; i<sum.length-1;i++){
                for (int j=0; j<sum.length-1;i++){
                       if (sum[j]<sum[j+1]){
                               int t = sum[j];   String t2 = str[j];
                               sum[j] = sum[j+1];  str[j] = str[j+1];
                               sum[j+1] = t;       str [j+1] = t2;
                           
                           }
                    }
               
                }
            
            //效果输出
            System.out.print("学生");
            for (int i=0; i<courseN.length; i++){
                  System.out.print("\t"+courseN[i]);
                  
                }
            System.out.print("\t总分\t平均分\t排行榜");
          System.out.println();
         
         
              
              for (int i=0; i<renshu; i++){
                  System.out.println(str[i]+"\t"+"第"+(i+1)+"门");
                  }
              
              
                  
                  
              
        
        }
   
   
    }
搜索更多相关主题的帖子: number public course import 
2016-03-11 18:15
快速回复:学生成绩 怎么输出不来
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.054863 second(s), 9 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved