main(){
int temp, n, loop, count=0;
int toggle;
clrscr();
printf("Masukkan nilai n : "); scanf("%d", &n);
loop = n/2;
for(int i=1;i<=n;i++){
printf("123");
if(i%2==0){
if(loop%2!=0){
if(count<=loop/2){
count++;
for(int j=1;j<=count;j++){
temp = 3 + j;
printf("%d", temp);
}toggle = count-1;
}else{
if(count>=loop/2){
for(int j=1;j<=toggle;j++){
temp = 3 + j;
printf("%d", temp);
}
toggle--;
}
}
}else{
if(count count++;
for(int j=1;j<=count;j++){
temp = 3 + j;
printf("%d", temp);
}
toggle = count;
}else{
if(count>=loop/2){
for(int j=1;j<=toggle;j++){
temp = 3 + j;
printf("%d", temp);
}
toggle--;
}
}
}
}
printf("\n");
}
getch();
}
Tidak ada komentar:
Posting Komentar