Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- #include <random>
- #include <time.h>
- using namespace std;
- bool symmetry(vector<vector<int>>& a) {
- if (a.size() == 1) return true;
- for (int i = 1; i < a.size(); ++i)
- for (int j = 0; j < i; ++j) {
- if (a[i][j] != a[j][i])
- return false;
- cout << j << '\n';
- }
- return true;
- }
- void fill_keyb(vector<vector<int>>& a) {
- for (int i = 0; i < a.size(); ++i) {
- for (int j = 0; j < a.size(); ++j) {
- int x = 0;
- cin >> x;
- a[i][j] = x;
- }
- }
- }
- void fill_rand(vector<vector<int>>& a) {
- for (int i = 0; i < a.size(); ++i)
- for (int j = 0; j < a.size(); ++j)
- a[i][j] = rand() % 100;
- cout << "Полученная матрица:\n";
- for (int i = 0; i < a.size(); ++i) {
- for (int j = 0; j < a.size(); ++j)
- cout << a[i][j] << " ";
- cout << '\n';
- }
- }
- int main() {
- srand(time(0));
- setlocale(LC_ALL, "Rus");
- cout << "Введите размер матрицы\n";
- int size = 0;
- cin >> size;
- vector<vector<int>> a(size, vector<int> (size, 0));
- cout << "Ввести элементы матрицы с клавиатуры (1) или заполнить случайными числами (0)?\n";
- int temp = 0;
- cin >> temp;
- if (temp == 1)
- fill_keyb(a);
- else
- fill_rand(a);
- if (symmetry(a))
- cout << "Матрица симметрична относительно главной диагонали\n";
- else
- cout << "Матрица ассимметрична относительно главной диагонали\n";
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement