fork download
  1.  
  2. #include<bits/stdc++.h>
  3. using namespace std;
  4.  
  5. int main() {
  6. int n;
  7. cin >> n;
  8. for (int i = 0; i < n; i++) {
  9. int spaces = i;
  10. if (i > n / 2) spaces = n - 1 - i;
  11. for (int j = 0; j < spaces; j++) cout << ' ';
  12. for (int j = 0; j < n - 2 * spaces; j++) cout << 'x';
  13. cout << '\n';
  14. }
  15. }
Success #stdin #stdout 0s 5332KB
stdin
5
stdout
xxxxx
 xxx
  x
 xxx
xxxxx