Untitled
unknown
plain_text
2 years ago
878 B
0
Indexable
Never
#include <iostream> using namespace std; int main() { int n; cout << "Enter an odd positive integer n: "; cin >> n; if (n <= 0 || n % 2 == 0) { cout << "Invalid input. Program terminated." << endl; return 0; } int center = n / 2; for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { if (i < center && j < center) { if (i == j) { cout << "*"; } else { cout << "+"; } } else if (i > center && j > center) { if (i == j) { cout << "*"; } else { cout << "x"; } } else { cout << " "; } } cout << endl; } return 0; }