Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <omp.h>
- #include <stdlib.h>
- #define const 50
- #define n 6
- #define m 6
- #define time 1200
- void main()
- {
- double mas_1[n][m], mas_2[n][m];
- for (int i = 0; i<n; i++)
- {
- printf("\n");
- for (int j = 0;j<m;j++)
- {
- if (i==0 || j==0 || i == (n - 1)|| j == (m-1)){
- mas_1[i][j] = 50;
- mas_2[i][j] = 50;
- }
- else
- {
- mas_1[i][j] = 0;
- mas_2[i][j] = 0;
- }
- printf("%f ", mas_1[i][j]);
- }
- }
- //заполнение массива.
- for (int l = 0; l < time; l++)
- {
- printf("\n-------------------------------------");
- for (int i = 1; i <n; i++)
- {
- printf("\n ");
- for (int j =1; j < m-1; j++)
- {
- mas_2[i][j] = 0.99*mas_1[i][j] + 0.01*(mas_1[i-1][j-1] + mas_1[i][j-1] + mas_1[i+1][j-1] + mas_1[i+1][j] + mas_1[i+1][j+1] + mas_1[i][j+1] + mas_1[i-1][j+1] + mas_1[i-1][j])/8;
- printf("%f ", mas_2[i][j]);
- }
- }
- for (int q=1;q<n; q++)
- {
- for (int w=1;w<m;w++)
- {
- mas_1[q][w] = mas_2[q][w];
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement