#include <iostream>
#include <iomanip>
void draw_x(int n) {
int r, c;
for (r = 1; r <= n; r++) {
for (c = 1; c <= n; c++) {
if (r == c || c == (n + 1) - r) {
std::cout << "*";
} else {
std::cout << "_";
}
}
std::cout << std::endl;
}
}
int main() {
int n;
std::cin >> n;
if (n % 2 == 0) {
std::cout << "Sorry, not odd" << std::endl;
} else {
draw_x(n);
}
}
Here is my code, how would I remove any extra underscores on the right after it is printed?
The image shows the underscore in the middle on the right and I dont know how to remove it within my code.
Aucun commentaire:
Enregistrer un commentaire