fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. void printGrid(int l, int c, int h, int w){
  5. string grid = "";
  6. int x = c * (w + 1) + 1, y = l * (h + 1) + 1;
  7. for (unsigned i = 0; i < y; i++){
  8. for (unsigned j = 0; j < x; j++){
  9. if (i % (h+1) == 0 || j % (w+1) == 0) grid += "*";
  10. else grid += ".";
  11. }
  12. grid += "\n";
  13. }
  14. cout << grid;
  15.  
  16. }
  17.  
  18. int main() {
  19. int t, l, c, h, w;
  20. cin >> t;
  21.  
  22. for (unsigned i = 0; i < t; i++){
  23. cin >> l >> c >>h >> w;
  24.  
  25. printGrid(l, c, h, w);
  26.  
  27. }
  28.  
  29. return 0;
  30. }
Success #stdin #stdout 0s 4148KB
stdin
3
3 1 2 1
4 4 1 2
2 5 2 2
stdout
***
*.*
*.*
***
*.*
*.*
***
*.*
*.*
***
*************
*..*..*..*..*
*************
*..*..*..*..*
*************
*..*..*..*..*
*************
*..*..*..*..*
*************
****************
*..*..*..*..*..*
*..*..*..*..*..*
****************
*..*..*..*..*..*
*..*..*..*..*..*
****************