国开 / 面向对象程序设计
public static void main(String[] args) {
int c0=0, c1=0, c2=0;
for(int x=1; x<=20; x++) {
switch(x%3) {
case 0: c0++; break;
case 1: c1++; break;
case 2: c2++; break;
}
}
System.out.println("c0,c1,c2="+c0+","+c1+","+c2);
}
c0,c1,c2=6,7,7
c0,c1,c2=7,6,6
int c0=0, c1=0, c2=0;
for(int x=1; x<=20; x++) {
switch(x%3) {
case 0: c0++; break;
case 1: c1++; break;
case 2: c2++; break;
}
}
System.out.println("c0,c1,c2="+c0+","+c1+","+c2);
}
c0,c1,c2=6,7,7
c0,c1,c2=7,6,6
参考答案:
佳题速递: