标题:学生成绩 怎么输出不来
只看楼主
X15810803158
Rank: 2
等 级:论坛游民
帖 子:49
专家分:36
注 册:2015-2-24
结帖率:91.67%
已结贴  问题点数:5 回复次数:3 
学生成绩 怎么输出不来
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
Laugher
Rank: 2
来 自:北京
等 级:论坛游民
帖 子:3
专家分:23
注 册:2016-3-11
得分:3 
顶顶

细节决定成败!
2016-03-12 16:27
sweetLR
Rank: 2
等 级:论坛游民
帖 子:9
专家分:23
注 册:2016-3-14
得分:3 
有点乱 看不清 等我耐心看看
2016-03-14 20:25
sweetLR
Rank: 2
等 级:论坛游民
帖 子:9
专家分:23
注 册:2016-3-14
得分:0 
没找到输出学生成绩的 语句啊 。 要培养习惯 写干净代码  你看看你写输出学生成绩了吗
2016-03-14 20:30



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-462378-1-1.html




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

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