fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5. int n;
  6. cin >> n;
  7. int middle = n / 2;
  8. for (int i = 0; i < n; ++i) {
  9. int upperIndex = i, lowerIndex = n - i - 1;
  10. for (int j = 0; j < n; ++j) {
  11. if ((j == middle - upperIndex || j == middle + upperIndex)
  12. || (j == middle - lowerIndex || j == middle + lowerIndex)) {
  13. cout << "*";
  14. } else {
  15. cout << " ";
  16. }
  17. }
  18. cout << "\n";
  19. }
  20. return 0;
  21. }
Success #stdin #stdout 0s 5288KB
stdin
3
stdout
 * 
* *
 *