对某些人来说这可能是非常基本的,但我似乎无法绕过它.我的任务指示是:
只应改变一个地方.而不是打印
Run Code Online (Sandbox Code Playgroud)1, 2, 3, 4, 5, 6, 7, 8, 9, 10打印:
Run Code Online (Sandbox Code Playgroud)99, 80, 63, 48, 35, 24, 15, 8, 3, 0
码:
public class Lab9
{
public static void main(String args[])
{
int counter;
counter=1; // do not change this line
while(counter<=10) // do not change this line
{
System.out.println(counter); // do change this line
counter=counter+1; // do not change this line
}
System.exit(0);
}
}
Run Code Online (Sandbox Code Playgroud)
模式比计数器的平方小一个(以相反的顺序)
public class Lab9{
public static void main(String args[])
{
int counter;
counter=1; // do not change this line
while(counter<=10) // do not change this line
{
System.out.println((11-counter)*(11-counter)-1); // do change this line
counter=counter+1; // do not change this line
}
System.exit(0);
}
}
Run Code Online (Sandbox Code Playgroud)