#include "stdafx.h"//del
#include <iostream>
#include <iomanip>
using namespace std;
int main()
{
const int N = 8;//квадратная матрица N x N
//создание
int **pMas = new int*[N]; //строки
for (int i = 0; i < N; i++)
pMas[i] = new int[N]; //столбцы
//заполнение
for (int i = 0; i < N; i++)
for (int j = 0; j < N; j++)
{
if (i == j) pMas[i][j] = 0;
if (i > j) pMas[i][j] = -1;
if (i < j) pMas[i][j] = 1;
}
//вывод
for (int i = 0; i < N; i++) {
for (int j = 0; j < N; j++) {
cout << setw(4) << pMas[i][j];
}
cout << endl;
}
for (int i = 0; i < N; i++)
delete[] pMas[i];
delete[] pMas;
return 0;
}
Be the first to comment
You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.