fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. void reserveSeat(int x, int y, char **tab)
  5. {
  6. if(tab[x][y]=='X')
  7. cout<<"Already Reserved"<<endl;
  8. else
  9. tab[x][y]='X';
  10.  
  11. }
  12.  
  13.  
  14.  
  15. int main() {
  16. char **tab = new char *[5];
  17. for(int i = 0; i<5; i++)
  18. {
  19. tab[i] = new char[4];
  20. }
  21. for (int i = 0; i<5; i++)
  22. for (int j = 0; j<4; j++)
  23. {
  24. tab[i][j] = 65 + j;
  25. }
  26.  
  27. reserveSeat(0,0,tab);
  28. reserveSeat(0,0,tab);
  29.  
  30. reserveSeat(3,3,tab);
  31.  
  32. for (int i = 0; i<5; i++)
  33. {
  34. cout<<i+1<<" ";
  35. for (int j = 0; j<4; j++)
  36. {
  37. cout<<tab[i][j]<<" ";
  38. }
  39. cout<<endl;
  40. }
  41.  
  42. // your code goes here
  43. return 0;
  44. }
Success #stdin #stdout 0s 15240KB
stdin
2 2
one
two
three
four
stdout
Already Reserved
1 X B C D 
2 A B C D 
3 A B C D 
4 A B C X 
5 A B C D