Untitled
unknown
c_cpp
2 years ago
908 B
7
Indexable
#include <iostream>
#include <vector>
#include <math.h>
bool isBorder(int x, int y, int n, int m) {
if ((x == 0) || (y == 0) || (x == n - 1) || (y == m - 1)) {
return true;
}
return false;
}
int main()
{
int n, m, x0, y0, x1, y1;
std::cin >> n >> m >> x0 >> y0 >> x1 >> y1;
double s = sqrt(pow(x1 - x0, 2) + pow(y1 - y0, 2));
std::vector<std::vector<char>> backYard(n, std::vector<char>(m, '.'));
for (int i = 0; i < n; i++) {
for (int j = 0; j < m; j++) {
if (isBorder(i, j, n, m)) {
backYard[i][j] = '#';
}
}
}
backYard[x0][y0] = '*';
backYard[x1][y1] = '$';
for (int i = 0; i < n; i++) {
for (int j = 0; j < m; j++) {
std::cout << backYard[i][j];
}
std::cout << '\n';
}
std::cout << s;
return 0;
}Editor is loading...
Leave a Comment