Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <math.h>
- #include <conio.h>
- #include <stdio.h>
- #include <time.h>
- #include <stdlib.h>
- int main() {
- const int SIZE = 10;
- int m, k, n, i, j, A[SIZE][SIZE], B[SIZE][SIZE];
- srand(time(NULL));
- printf("Input dimention (max = 10) of array: n rows and columns\n");
- do
- {
- printf("Input n [1..10] = ");
- scanf_s("%d", &n);
- } while ((n < 1) || (n > SIZE));
- for (i = 0; i < n; i++)
- {
- for (j = 0; j < n; j++)
- {
- A[i][j] = 2;
- }
- }
- for (i = 0; i < n; i++)
- {
- for (j = 0; j < n; j++)
- {
- B[i][j] = 0;
- }
- }
- for (int i = 0; i <= n; i++)
- {
- for (int j = 0; j <= n; j++)
- {
- for ( k = i; k < n; k++)
- {
- for ( m = j; m < n; m++)
- {
- B[i][j] += A[k][m];
- }
- }
- }
- }
- printf("\n\t -- ARRAY --\n");
- for (i = 0; i < n; i++)
- {
- for (j = 0; j < n; j++)
- {
- printf("%d\t", B[i][j]);
- }
- printf("\n");
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement