这对某些人来说可能是非常基本的,但我似乎无法理解它。我的作业方向是:
Only one place should be changed. Instead of printing
1, 2, 3, 4, 5, 6, 7, 8, 9, 10
make it print:
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);
}
}
最佳答案
图案比计数器的平方小一(逆序)
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);
}
}
关于java - 在所需的输出中查找模式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35561619/