#include "stdafx.h"//del
#include <iostream>
#include <iomanip>
using namespace std;
int main()
{
int N = 0;
while (true)
{
cout << "N =";
cin >> N;
if (N < 2) cout << endl << "Not corect N. N > 1!";
else
break;
}
//создание
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] = 1;
else
pMas[i][j] = 0;
}
int SELECT = 0;//+
//вывод
cout << endl;
for (int i = 0; i < N; i++) {
for (int j = 0; j < N; j++)
{
if ((pMas[i][j] == 1) && (SELECT == 0))
{
cout << "+";
SELECT = 1;
}
else if ((pMas[i][j] == 1) && (SELECT == 1))
{
cout << "*";
SELECT = 0;
}
else cout << " ";
}
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.