- 1

Java

perulangan bersarang / Nester if menggunakan for. Dengan output : 01234 12340 23401 34012 40123

19th Dec 2017, 3:28 PM
Rian Pratama
Rian Pratama - avatar
4 Réponses
+ 2
English?
19th Dec 2017, 4:12 PM
Lucien
Lucien - avatar
+ 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 } } }
19th Dec 2017, 4:47 PM
Boris Batinkov
Boris Batinkov - avatar
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 } } }
19th Dec 2017, 10:40 PM
Rian Pratama
Rian Pratama - avatar
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
19th Dec 2017, 10:44 PM
Rian Pratama
Rian Pratama - avatar