fork(3) download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5. int n, x;
  6. cin >> n;
  7. for (int l = 0; l < n; l ++){
  8. cin >> x;
  9. for (int j = 0; j < x; j ++){
  10. for (int i = 0; (i <= j) or (i <= x - 1 - j); i ++){
  11. if ((i == j) or (j == x - 1 - i)) cout << "X";
  12. else cout << " ";
  13. }
  14. cout << endl;
  15. }
  16. cout << endl;
  17. }
  18. return 0;
  19. }
Success #stdin #stdout 0s 15232KB
stdin
3 5 3 1
stdout
X   X
 X X
  X
 X X
X   X

X X
 X
X X

X