Topic: (,;expected)问题

  Print this page

1.(,;expected)问题 Copy to clipboard
Posted by: ddddddv
Posted on: 2007-02-20 14:12

看了一篇关于这个问题的帖子,那个是忘了一个;号 我看过了 自己好象不是这原因,请各位大虾指点。初次写这个。

ublic class score {
public static void main(String[] args) {
int[] units={32,87,70,66,90,15,
21,88,93,75,52,30};
for(int i=0,j=1;i<units.length,j<units.length; ) {
if(units[i]>=units[j]) {
j++;
} else {
i++;
}
System.out.println("this is the high score"+units[i]);
}
for(int a=0,b=1;a<units.length,b<units.length; ) {
if(units[a]<=units[b]) {
b++;
}else {
a++;
}
System.out.println("this is the low score"+units[a]);
}
for(int c=0,d=0,e=0,f=0;c<units.length,d<units.length,
e<units.length,f<units.length;c++) {
if(units[c]>80) {
d++;
}else if (units[c]>60 && units[c]<=80) {
e++;
} else {
f++;
}
System.out.println("Good="+d+" "+"Ok="+e+" "+"Bad="+f);
}
for(int g=0,k=1;g<units.length,k<units.length;k++) {
units[g]+=units[k];
units[g]=units[g]/units.length;
System.out.println("the average score is"+units[g]);
}
System.out.println();
}
}

2.Re:(,;expected)问题 [Re: ddddddv] Copy to clipboard
Posted by: ddddddv
Posted on: 2007-02-20 19:50

还有这个题目是这样的:程序要可以找出一个班级某次考试成绩的最高分、最低分,并能统计优秀(80分以上)、及格(60分到80分)和不及格的人数以及全班平均分。

小弟第一次写程序,还请各位不吝赐教。

3.Re:(,;expected)问题 [Re: ddddddv] Copy to clipboard
Posted by: why
Posted on: 2007-02-22 08:53

for(int a=0,b=1;(a<units.length || b<units.length); ) {

==========

int high = 0;
int low = 100;
int total = 0;
int numGood = 0;
int numPassed = 0;
int numFailed = 0;

for (int i=0; i<units.length; i==) {
int v = units[i];
total += v;
if (v > high) {
high = v;
} else if (v < low) {
low = v;
}

if (v > 80) {
numGood++;
} else if (v >= 60) {
numPassed++;
} else {
numFailed++;
}
}


   Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent
Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1
客服电话 18559299278    客服信箱 714923@qq.com    客服QQ 714923