Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #define N 11
- #define M 11
- void cross(int **tab, int start_w, int start_k, int stop_w, int stop_k);
- int main ( void )
- {
- int** t = (int**)calloc(N,sizeof(int*));
- for(int i = 0; i < N; i++)
- {
- t[i] = (int*)calloc(M,sizeof(int));
- }
- cross(t,0,0,N-1,M-1);
- for(int i = 0; i < N; i++)
- {
- printf("\n");
- for(int j = 0; j < M; j++)
- {
- printf("%c ",t[i][j]);
- }
- }
- return 0;
- }
- void cross(int **tab, int start_w, int start_k, int stop_w, int stop_k)
- {
- if((stop_w - start_w <= 1) || (stop_k - start_k <= 1))
- {
- return;
- }
- int half_k = (start_w + stop_w) / 2;
- int half_w = (start_k + stop_k) / 2;
- for(int i = start_w; i <= stop_w; i++)
- {
- tab[i][half_w] = '*';
- }
- for(int i = start_k; i <= stop_k; i++)
- {
- tab[half_k][i] = '*';
- }
- cross(tab, start_w, start_k, half_k-1, half_w-1);
- cross(tab, half_k+1, half_w+1, stop_w, stop_k);
- cross(tab, start_w, half_w+1, half_k-1, stop_k);
- cross(tab, half_k+1,start_k,stop_w,half_w-1);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement