- 1
Java
perulangan bersarang / Nester if menggunakan for. Dengan output : 01234 12340 23401 34012 40123
4 Antworten
+ 2
English?
+ 2
import java.util.Scanner;
public class Program
{
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
int len = Integer.parseInt(scan.nextLine());
for (int i = 0, n; i <= len; i++) {
n = i; // Keep 'i' for next row
for (int j = 0; j < len; j++) {
System.out.print(i++);
if (i > len) {
i = 0;
}
}
System.out.println(i);
i = n; // Restore 'i' for next row
}
}
}
0
Sory, coding don't work.
I want to array nested looping, help
import java.util.Scanner;
public class Program
{
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
int len[5]={0,1,2,3,4}
for (int i = 0, n; i <=5; i++) {
n = i; // Keep 'i' for next row
for (int j = 0; j <5; j++) {
System.out.print(i++);
if (i > l5) {
i = 0;
}
}
System.out.println(i);
i = n; // Restore 'i' for next row
}
}
}
0
#Lucien
Hy, can you help me?
I want to simple program use nested looping ( for) array 2 dimensi, without the input.
Output :
01234
12340
23401
34012
40123
and next until 01234