Admin2 12 Report post Posted May 15, 2008 Saya ada masalah ngan coding nested loopMacam saya nak print yang ni112123123412345 coding dia macam ni#include <stdio.h> int main() { int i, j; for (i=1; i<=5; i++) { for (j=1;j<=i;j++) { printf("%d", j); } printf("\n"); } }camne nak print yang ni:543214321321211hurmm ada sape2 yang tau? betik.............?? hehe. sape2 ke.. Quote Share this post Link to post Share on other sites
mykk 0 Report post Posted May 16, 2008 kodnya sama seperti diatas cuma reverse sahajafor(i = 5; i >= 1; i--) { for(j = i; j >= 1; j--) { printf("%d", j); } printf("\n"); } Quote Share this post Link to post Share on other sites
Admin2 12 Report post Posted May 16, 2008 huhu thanx2. camne kalau yang ni pulak? 543215432543545macam susah je.. Quote Share this post Link to post Share on other sites
mykk 0 Report post Posted May 17, 2008 for(i = 1; i <= 5; i++) { for(j = 5; j >= i; j--) { printf("%d", j); } printf("\n"); } Quote Share this post Link to post Share on other sites
Admin2 12 Report post Posted May 18, 2008 huhu thanx mykk. 5 bintang for u. nanti ada apa2 problem ngan nested loop sy post kat sini ok. thanx sekali lagi Quote Share this post Link to post Share on other sites