fork download
  1. #include <iostream>
  2. #include<sstream>
  3. #include<cstdio>
  4. using namespace std;
  5.  
  6. void PrintGardenLayout() {
  7.  
  8. int n,m;
  9. scanf("%d,%d", &n,&m);
  10.  
  11. cout<<n<<m<<endl;
  12. if(n==0 || m==0)
  13. return;
  14.  
  15. char textLayout[n][m];
  16.  
  17. for(int i=0;i<n;i++)
  18. {
  19. for(int j=0;j<m;j++)
  20. {
  21. textLayout[i][j] = 'B';
  22. }
  23. }
  24.  
  25. std::string line;
  26. for(; std::getline(std::cin, line);)
  27. {
  28. std::cout<<line<<endl;
  29. std::istringstream stream(line);
  30.  
  31. string token;
  32. int tokenCnt=0;
  33. char charToPut='B';
  34. int x = 0;
  35. int y = 0;
  36. while(std::getline(stream, token, ','))
  37. {
  38. if(tokenCnt==0)
  39. {
  40. charToPut = (token == "F" ? 'F' : 'W');
  41. }
  42. else if(tokenCnt==1)
  43. {
  44. x = stoi(token);
  45. }
  46. else if(tokenCnt == 2)
  47. {
  48. y = stoi(token);
  49. }
  50.  
  51. tokenCnt++;
  52. }
  53.  
  54. textLayout[x][y] = charToPut;
  55. }
  56.  
  57. for(int i=0;i<n;i++)
  58. {
  59. for(int j=0;j<m;j++)
  60. {
  61. cout<<textLayout[i][j]<<" ";
  62. }
  63. cout<<endl;
  64. }
  65.  
  66. }
  67.  
  68. int main() {
  69. // your code goes here
  70.  
  71. PrintGardenLayout();
  72. return 0;
  73. }
Success #stdin #stdout 0s 4564KB
stdin
2, 2
F, 0 , 1
W, 1, 1
stdout
22

F, 0 , 1
W, 1, 1
B F 
B W