Wlcome to the blogging tifani

Program C++ Bilangan Ganjil Berpola

Jumat, 24 Oktober 20140 komentar

#include<cstdio>
#include<algorithm>
#include<conio.h>
int main(){
int n;
printf("\t\t===-----------------------------===\n");
printf("\t\t|BILANGAN INTEGER GANJIL BERPOLA|\n");
printf("\t\t===-----------------------------===\n");
printf("Input jumlah pola : ");
scanf(" %d",&n);
printf("\n\n");
n= n/2 + 1;

int a[n*3][n*3];
memset(a,0,sizeof(a));

for(int i=0;i<n;i++){
int d=i*2+1;
for (int j=(-i);j<=i;j++){
a[n-i-1][j+n-1]=d;
a[i+n-1][j+n-1]=d;
a[n+j-1][n-i-1]=d;
a[j+n-1][i+n-1]=d;
if (d%2) {d--;}
else {d++;}
}
}

for (int i=0;i<=((n*2)-2);i++){
for (int j=0;j<=((n*2)-2);j++){
printf("  %d",a[i][j]);
}
printf("\n\n");

}
printf("\t\t\t\t\t\t created by Asep Nur Muhammad");
printf("\t\t\t\t\t\t\t\t\t140810140070");
getch();
}


Share this article :

Posting Komentar

 
Support : Cara Gampang | Creating Website | Johny Template | Mas Templatea | Pusat Promosi
Copyright © 2015. TIfanie - All Rights Reserved
Template edited by Creating Website Modify by Teknologi Informasi kinie
Proudly powered by Blogger