gpt4 book ai didi

java - 在所需的输出中查找模式

转载 作者:行者123 更新时间:2023-12-01 06:42:54 25 4
gpt4 key购买 nike

这对某些人来说可能是非常基本的,但我似乎无法理解它。我的作业方向是:

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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com