Java – try sliding windows
•
Java
I try to print images like sliding windows I can't do it right Therefore, when the sliding window size is 1, it should print each element When the sliding window is 2, it should print two consecutive elements
0 1 2 01 12 0123
Please check this Code:
for(int w = 1; w <= a.length; w++) {
System.out.println("Window size : " + w);
for(int i = 0; i < a.length; i++) {
for(int j = i; j < w; j++) {
System.out.println(j);
}
System.out.println();
}
}
Solution
for(int w = 1; w <= a.length; w++){
for(int w = 1; w <= a.length; w++){
System.out.println("Window size : " + w);
for(int i = 0; i < a.length - w + 1; i++){
for(int j = i; j < i + w; j++){
System.out.print(a[j]);
}
System.out.println();
}
}
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码
