Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <cstdio>
- using namespace std;
- int main()
- {
- int N, i, j;
- int half;
- printf("Nilai N : ");
- scanf("%d", &N);
- half = N/2;
- for (i=0; i<N; i++)
- {
- for (j=0; j<N; j++)
- {
- if ((i==0) || (i==N-1) || (j==0) || (j==N-1))
- {
- printf("%%");
- } else if (N%2) {
- if ((j==half-i) || (j==N-i+half-1)) {
- printf("3");
- }
- else if ((j==half+i) || (j==i-half)) {
- printf("2");
- } else {
- printf(" ");
- }
- } else {
- if ((j==half-i) || (j==N-i+half-2)) {
- printf("3");
- }
- else if ((j==half+i-1) || (j==i-half+1)) {
- printf("2");
- } else {
- printf(" ");
- }
- }
- }
- printf("\n");
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement