| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 933 人关注过本帖
标题:数组问题,请教,大家帮忙
只看楼主 加入收藏
jasonwing27
Rank: 1
等 级:新手上路
帖 子:7
专家分:0
注 册:2004-9-5
收藏
 问题点数:0 回复次数:2 
数组问题,请教,大家帮忙

import java.io.* ; public class ExamResult1 { public ExamResult1() { } public static void main(String args[]) { int total = 0 ; int average = 0 ; int stuResult[] = new int[31] ; int stuNumber[] = new int[31] ; String stuName[] = {"","jason" ,"kitty" ,"Ken","San","King", "David","Jerry","Heary","Abs","Coll", "LI","Zhang","Kiki","KAKA","COCO", "Paul","mC","Wade","Nice","Fore", "Opio","Kiss","Kirt","Kurt","Coke", "Frant","OL","eYE","Joe","KK"} ; System.out.println("NAME\t学号\t成绩") ; for (int count = 1 ; count <= 31 ; count++) { stuResult[count] = 1 + (int)(Math.random() * 100 ) ; stuNumber[count] = count ; System.out.println(stuName[count] + "\t" + stuNumber[count] + "\t" + stuResult[count]) ; total += stuResult[count] ; } average = total/30 ; System.out.print("总成绩为" + total); System.out.print("平均成绩为" + average); } }

可以打印出来成绩,学号和姓名,但是打印不出总成绩和平均成绩 。

搜索更多相关主题的帖子: average public import kitty 
2004-12-09 19:25
tailys
Rank: 1
等 级:新手上路
帖 子:21
专家分:0
注 册:2004-8-16
收藏
得分:0 
runtime ArrayIndexOutOfBoundsException,count = 31的时候抛出,自然之后的不会运行了,count&lt;=30 或者count&lt;31
2004-12-10 09:00
pyzheng
Rank: 1
等 级:新手上路
帖 子:102
专家分:0
注 册:2004-12-5
收藏
得分:0 
count &lt;= 31 是不是应该为count&lt;31!!!!!!!!!!1

-----------人間太苦﹐成仙太難------------
2004-12-14 11:12
快速回复:数组问题,请教,大家帮忙
数据加载中...
 
   



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

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