fork download
  1. #include <iostream>
  2.  
  3. void out_square(std::ostream& _o, int num, int cnt){
  4. bool chk;
  5. int len = num - 1;
  6. for(int i = 0; i < num; ++i){
  7. chk = (i < cnt || i > len-cnt);
  8. for(int j = 0; j < num; ++j){
  9. if((j < cnt) || (j > len-cnt) || chk)
  10. _o << '*';
  11. else
  12. _o << ' ';
  13. }
  14. _o << std::endl;
  15. }
  16. _o.flush();
  17. }
  18.  
  19.  
  20. int main(void){
  21. out_square(std::cout, 12, 2);
  22. return 0;
  23. }
Success #stdin #stdout 0s 3140KB
stdin
Standard input is empty
stdout
************
************
**        **
**        **
**        **
**        **
**        **
**        **
**        **
**        **
************
************