public class Test{
public static void main(String[] args){
int[] a = {3, 2, 5, 21}; // created an array with 4 elements
int b,c;
for (b=0; b<=2; b++)//for loop that will have 3 iterations
{
if (a[b] < a[b+1])
{
c=a[b];//this
a[b] = a[b+1];//is
a[b+1] = c;//swapping
}
}
for(b=0; b<4; b++)
{
System.out.println(a[b]);
}
}
}
これは出力します:
3
5
21
2
私がそれを書き留めていたときに私が得たもの:
3
5
21
21
誰かが私の考えでそれにアプローチする方法を教えてもらえますか?