#include <bits/stdc++.h>
using namespace std;
int main()
{
char a[8][8];
long long x, y, i, j;
cin >> y >> x;
for(i = 0; i < 8; i++){
for(j = 0; j < 8; j++){
a[i][j] = '.';
}
}
x--;
y--;
if(x - y >= 0){
i = 0;
j = x - y;
}
else{
j = 0;
i = y - x;
}
for(;i < 8 and j < 8;){
a[i][j] = '*';
i++;
j++;
}
if(x + y <= 7){
i = 0;
j = x + y;
}
else{
j = 7;
i = x + y - 7;
}
for(;i < 8 and j >= 0;){
a[i][j] = '*';
i++;
j--;
}
i = 0;
j = x;
for(;i < 8; i++){
a[i][j] = '*';
}
i = y;
j = 0;
for(;j < 8; j++){
a[i][j] = '*';
}
a[y][x] ='Q';
for(i = 0; i < 8; i++){
for(j = 0; j < 8; j++){
cout << a[i][j] << " ";
}
cout << '\n';
}
return 0;
}
Объяснение:
#include <iostream>
#include<stdlib.h>
/*
В прямоугольной целочисельной матрице упорядочить элементы, которые размещены на главной диагонале по убыванию
*/
using namespace std;
int main() {
setlocale(LC_ALL,"rus");
cout << "Masiv do sortirovki "<< endl << endl;
int mas[5][5];
for(int i=0; i<5; i++){
for(int j=0; j<5; j++){
mas[i][j]=-10+rand()%90;
cout<<mas[i][j]<<" ";
}
cout << endl;
}
cout << endl << endl;
cout << "Masiv posle sortirovki "<< endl << endl;
/* сортировку тут нужно провести */
for(int i=0; i<5; i++){
for(int j=0; j<5; j++){
cout<<mas[i][j]<<" ";
}
cout << endl;
}
cout << endl << endl;
return 0;
сорри если не правильно.(