Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- const int n = 5;
- void unos(int[][n]);
- void ispis(int[][n]);
- bool pogl(int[][n]);
- bool posp(int[][n]);
- bool posc(int[][n]);
- int main()
- {
- int mat[n][n];
- unos(mat);
- ispis(mat);
- if (pogl(mat)) cout << "Simetricna po glavnoj dijagonali." << endl;
- else if (posp(mat)) cout << "Simetricna po sporednoj dijagonali." << endl;
- else if (posc(mat)) cout << "Simetricna po srednjem clanu." << endl;
- return 0;
- }
- void unos(int mat[][n])
- {
- int m = n, i = 0, j = 0;
- for (int o = 1; o <= n / 2; o++)
- {
- for (j; j < m; j++) cin >> mat[i][j];
- j--;
- for (++i; i < m; i++) cin >> mat[i][j];
- i--;
- for (--j; j >= n - m; j--) cin >> mat[i][j];
- j++;
- for (--i; i >= o; i--) cin >> mat[i][j];
- m--;
- i = j = o;
- }
- if (n % 2 == 1)
- cin >> mat[n / 2][n / 2];
- }
- void ispis(int mat[][n])
- {
- for (int i = 0; i < n; i++)
- {
- for (int j = 0; j < n; j++)
- cout << mat[i][j] << "\t";
- cout << endl;
- }
- }
- bool pogl(int mat[][n])
- {
- for (int i = 0; i < n; i++)
- {
- for (int j = 0; j < n; j++)
- {
- if (mat[i][j] != mat[j][i])
- return false;
- }
- }
- return true;
- }
- bool posp(int mat[][n])
- {
- for (int i = 0; i < n; i++)
- {
- for (int j = 0; j < n; j++)
- {
- if (mat[i][j] != mat[n - 1 - j][n - 1 - i])
- return false;
- }
- }
- return true;
- }
- bool posc(int mat[][n])
- {
- for (int i = 0; i < n; i++)
- {
- for (int j = 0; j < n; j++)
- {
- if (mat[i][j] != mat[n - 1 - i][n - 1 - j])
- return false;
- }
- }
- return true;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement