Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //https://vk.com/evgenykravchenko0
- ___ ___ ___
- / /\ ___ / /\ / /\
- / /:/_ /__/\ / /:/_ / /:/_
- / /:/ /\ \ \:\ / /:/ /\ / /:/ /\
- / /:/ /:/_ \ \:\ / /:/_/::\ / /:/ /:/_
- /__/:/ /:/ /\ ___ \__\:\ /__/:/__\/\:\ /__/:/ /:/ /\
- \ \:\/:/ /:/ /__/\ | |:| \ \:\ /~~/:/ \ \:\/:/ /:/
- \ \::/ /:/ \ \:\| |:| \ \:\ /:/ \ \::/ /:/
- \ \:\/:/ \ \:\__|:| \ \:\/:/ \ \:\/:/
- \ \::/ \__\::::/ \ \::/ \ \::/
- \__\/ ~~~~ \__\/ \__\/
- ___
- /__/\ ___ ___
- \ \:\ / /\ / /\
- \ \:\ / /:/ / /:/
- _____\__\:\ /__/::\ /__/::\
- /__/::::::::\ \__\/\:\__ \__\/\:\__
- \ \:\~~\~~\/ \ \:\/\ \ \:\/\
- \ \:\ ~~~ \__\::/ \__\::/
- \ \:\ /__/:/ /__/:/
- \ \:\ \__\/ \__\/
- \__\/
- #include <stdio.h>
- #include <stdlib.h>
- #include <time.h>
- int main()
- {
- int i;
- int j;
- int matrix[4][4];
- int m;
- int n;
- int helix[4*4];
- int temp = 0;
- srand(time(NULL));
- printf("Матрица : \n");
- for(i = 0;i < 4;i++)
- {
- for(j = 0;j < 4;j++)
- {
- matrix[i][j] = rand() % (10);
- printf(" %d ", matrix[i][j]);
- }
- printf("\n");
- }
- printf("Обход : \n");
- m = n = 4;
- j=0;
- while(j < n)
- {
- i = 4 - m;
- j = 4 - n;
- while(j < n)
- {
- helix[temp] = matrix[i][j];
- temp++;
- j++;
- }
- j--;
- for(i++;i < m;i++)
- {
- helix[temp] = matrix[i][j];
- temp++;
- }
- i--;
- for(j--;j >= 4 - n;j--)
- {
- helix[temp] = matrix[i][j];
- temp++;
- }
- j++;
- for(i--;i > 4 - n;i--)
- {
- helix[temp] = matrix[i][j];
- temp++;
- }
- i++;
- m--;
- n--;
- }
- for(i= 4 * 4 - 1;i >= 0;i--)
- printf(" %d ", helix[i]);
- printf("\n");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement