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