for(;score<=60;count++){
score=score+count;
}
System.out.println("加分后成绩:"+score);
System.out.println("共加了"+count+"次!");
因为你的score变量加的是count变量,而count变量每次循环加1,所以你的程序实际的运行过程是:
第一次循环:score = 53 + 0 = 53; count = 0 + 1 = 1;
第二次循环:score = 53 + 1 = 54; count = 1 + 1 = 2;
第三次循环:score = 54 + 2 = 56; count = 2 + 1 = 3;
第四次循环:score = 56 + 3 = 59; count = 3 + 1 = 4;
第五次循环:score = 59 + 4 = 63; count = 4 + 1 = 5;
跳出循环
你把count在循环里面,再count++,那你想想最后一次循环是score加几?