Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void dotablicy(float **a, int n, int m)
- {
- float **b;
- int ilosc;
- float suma = 0;
- b = (float**)malloc(sizeof(float*)*n);
- for (int i = 0; i < n; i++)
- {
- b[i] = (float*)malloc(sizeof(float)*m);
- }
- for (int i = 0; i < n; i++)
- {
- for (int j = 0; j < m; j++)
- {
- b[i][j] = a[i][j];
- }
- }
- for (int i = 0; i < n; i++)
- {
- for (int j = 0; j < m; j++)
- {
- suma = 0;
- ilosc = 1;
- suma = suma + b[i][j];
- if (i - 1 < 0)
- {
- }
- else
- {
- ilosc++;
- suma = suma + b[i - 1][j];
- }
- if (i + 1 > n-1)
- {
- }
- else
- {
- ilosc++;
- suma = suma + b[i + 1][j];
- }
- if (j + 1 > m-1)
- {
- }
- else
- {
- ilosc++;
- suma = suma + b[i][j + 1];
- }
- if (j - 1 < 0)
- {
- }
- else
- {
- ilosc++;
- suma = suma + b[i][j - 1];
- }
- float srednia = suma / ilosc;
- a[i][j] = srednia;
- }
- }
- }
- void kolos1()
- {
- float **a;
- a = (float**)malloc(sizeof(float*)*8);
- for (int i = 0; i < 8; i++)
- {
- a[i] = (float*)malloc(sizeof(float)*6);
- }
- for (int i = 0; i < 8; i++)
- {
- for (int j = 0; j < 6; j++)
- {
- a[i][j] = rand() % 90 + 10;
- printf("%f ", a[i][j]);
- }
- printf("\n");
- }
- dotablicy(a, 8, 6);
- printf("\n");
- printf("\n");
- for (int i = 0; i < 8; i++)
- {
- for (int j = 0; j < 6; j++)
- {
- printf("%f ", a[i][j]);
- }
- printf("\n");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement