Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <math.h>
- int s = 0;
- void rpt_space(int s_n, int a)
- {
- int k = a - s_n;
- while(k--)
- {
- printf(" ");
- }
- }
- int no_size(int x)
- {
- int s_n = 0;
- while(x != 0)
- {
- x /= 10;
- s_n++;
- }
- return s_n;
- }
- int main ()
- {
- int N, i, j, big;
- while (1)
- {
- int s_n = 0, s = 0;
- scanf("%d", &N);
- if (N == 0) break;
- int m[N][N];
- big = ceil(pow(2, 2 * N - 2));
- while(big != 0)
- {
- big /= 10;
- s++;
- }
- for (i = 0; i < N; ++i)
- {
- for (j = 0; j < N; ++j)
- {
- m[i][j] = ceil(pow(2, i + j));
- rpt_space(no_size(m[i][j]), s);
- if (j != N - 1) printf("%d ", m[i][j]);
- else printf("%d", m[i][j]);
- }
- printf("\n");
- }
- printf("\n");
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement