Advertisement
Guest User

lab4

a guest
Nov 12th, 2019
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.97 KB | None | 0 0
  1. #include <math.h>
  2. #include <conio.h>
  3. #include <stdio.h>
  4. #include <time.h>
  5. #include <stdlib.h>
  6.  
  7. int main() {
  8.  
  9. const int SIZE = 10;
  10. int m, k, n, i, j, A[SIZE][SIZE], B[SIZE][SIZE];
  11. srand(time(NULL));
  12.  
  13. printf("Input dimention (max = 10) of array: n rows and columns\n");
  14. do
  15. {
  16. printf("Input n [1..10] = ");
  17. scanf_s("%d", &n);
  18. } while ((n < 1) || (n > SIZE));
  19.  
  20. for (i = 0; i < n; i++)
  21. {
  22. for (j = 0; j < n; j++)
  23. {
  24. A[i][j] = 2;
  25. }
  26. }
  27.  
  28. for (i = 0; i < n; i++)
  29. {
  30. for (j = 0; j < n; j++)
  31. {
  32. B[i][j] = 0;
  33. }
  34. }
  35.  
  36. for (int i = 0; i <= n; i++)
  37. {
  38. for (int j = 0; j <= n; j++)
  39. {
  40.  
  41. for ( k = i; k < n; k++)
  42. {
  43. for ( m = j; m < n; m++)
  44. {
  45. B[i][j] += A[k][m];
  46. }
  47. }
  48. }
  49. }
  50.  
  51. printf("\n\t -- ARRAY --\n");
  52. for (i = 0; i < n; i++)
  53. {
  54. for (j = 0; j < n; j++)
  55. {
  56. printf("%d\t", B[i][j]);
  57. }
  58. printf("\n");
  59. }
  60.  
  61.  
  62. return 0;
  63. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement