Selasa, 30 Oktober 2012

Source code C++ segi lima

    1             2          3
    1             2          3          4
    1             2          3         
    1             2          3          4          5
    1             2          3         
    1             2          3          4
    1             2          3



#include
#include

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