Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <ctime>
- #include <stdlib.h>
- using namespace std;
- const int N = 5;
- void naplneni(double **pole, const int N)
- {
- for (int i = 0; i < N; i++)
- {
- for (int j = 0; j < N; j++)
- {
- pole[i][j] = rand() % 100;
- }
- }
- }
- void tisk( double **pole ,const int N)
- {
- for (int i = 0; i < N; i++)
- {
- for (int j = 0; j < N; j++)
- {
- cout << pole[i][j] << "\t" ;
- }
- cout << endl;
- }
- }
- void vypocet(double **pole, const int N )
- {
- double prevyseni, D, uhel_sklonu;
- for (int i = 1; i < N-1; i++)
- {
- double tmp = 10 ;
- for (int j = 1; j < N - 1; j++)
- {
- for (int k = i-1; k <= i+1; k++)
- {
- for (int l = j-1; l <= j+1; l++)
- {
- if ((k != i) || (l != j) )
- {
- prevyseni = pole[i][j] - pole[k][l];
- D = (i - k)*(i - k) + (j - l)*(j - l);
- D = sqrt(D);
- uhel_sklonu = prevyseni / D;
- uhel_sklonu = atan(uhel_sklonu);
- cout << uhel_sklonu << "\t" ;
- if (uhel_sklonu < tmp)
- {
- tmp = uhel_sklonu;
- }
- }
- else cout << "\t" ;
- } cout << endl;
- } cout << "Nejmensi uhel sklonu je: " << tmp << endl;
- cout << endl;
- }
- }
- }
- int main()
- {
- double **pole = new double*[N];
- for (int i = 0; i < N; i++)
- {
- pole[i] = new double[N];
- }
- srand(time(NULL));
- naplneni(pole,N);
- tisk(pole ,N);
- cout << endl;
- vypocet(pole ,N);
- for (int i = 0; i < N; i++)
- {
- delete[]pole[i];
- }
- delete[]pole;
- cin.get();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement