SHARE
TWEET

Untitled

a guest Oct 21st, 2019 75 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <time.h>
  2. #include <locale.h>
  3. #include <stdio.h>
  4. #include <stdlib.h>
  5. #include <conio.h>
  6. int main()
  7. {
  8. int n, i, j, min, max, left, right, top, bottom, im, jm, t, kj, ki, k;
  9. setlocale(LC_ALL, "rus");
  10. srand(time(0));
  11. i = 0, j = 0;
  12. max = -10000;
  13. signed int mat[8][10];
  14. signed int mat0[10][12];
  15. //генерация матрицы mat
  16. printf_s("Матрица \n");
  17. for (int i = 0; i < 8; i++)
  18. {
  19. for (int j = 0; j < 10; j++)
  20. {
  21. mat[i][j] = rand() % 90 - 10;
  22. printf_s("%10d", mat[i][j]);
  23. }
  24. printf_s("\n");
  25. }
  26. //генерация матрицы mat0
  27. printf_s("Матрица c нулями \n");
  28. for (int i = 0; i < 10; i++)
  29. {
  30. for (int j = 0; j < 12; j++)
  31. {
  32. mat0[i][j] = rand() % 1 - 0;
  33. printf_s("%10d ", mat0[i][j]);
  34. }
  35. printf_s("\n");
  36. }
  37. printf_s("Матрица c заменой \n");
  38. for (int i = 0; i < 9; i++)
  39. {
  40. for (int j = 0; j < 11; j++)
  41. {
  42. mat0[i + 1][j + 1] = mat[i][j];
  43. }
  44. }
  45. for (int i = 0; i < 10; i++)
  46. {
  47. for (int j = 0; j < 12; j++)
  48. {
  49. mat0[9][j] = rand() % 1 - 0;
  50. mat0[i][11] = rand() % 1 - 0;
  51. printf_s("%10d ", mat0[i][j]);
  52. 6
  53. }
  54. printf_s("\n");
  55. }
  56. for (int i = 0; i < 10; i++)
  57. {
  58. for (int j = 0; j < 12; j++)
  59. {
  60. if (i > 0 && i < 9 && j>0 && j < 11) {
  61. k=mat0[i][j - 1] + mat0[i][j + 1] +
  62. +mat0[i + 1][j] + mat0[i - 1][j] ;
  63. if (k >= max) {
  64. max = k;
  65. kj = j;
  66. ki = i;
  67. }
  68. }
  69. }
  70. }
  71. printf_s("\n");
  72. printf_s("Cумма равна:%10d; Элемент i=%10d j =%10d", max, ki, kj);
  73. _getch();
  74. return 0;
  75. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top