fork download
  1. #include <iostream>
  2. #include <string>
  3. #include <vector>
  4. using namespace std;
  5.  
  6. void as(vector<vector<char>> &p, int n, int m)
  7. {
  8. p.resize(n);
  9. int i, j;
  10. for (i = 0; i < n; i++) {
  11. p[i].resize(m);
  12. for (j = 0; j < m; j++)
  13. {
  14. cout << "p[" << i << "][" << j << "]=";
  15. cin >> p[i][j];
  16. }
  17. }
  18. }
  19.  
  20. int main()
  21. {
  22. vector<vector<char>>a;
  23. as(a, 3, 3);
  24. cout<<endl;
  25. for (int i=0; i<3; i++) {
  26. for (int j=0; j<3; j++)
  27. cout << a[i][j];
  28. cout << endl;
  29. }
  30. return 0;
  31. }
  32.  
Success #stdin #stdout 0s 16064KB
stdin
abcdefghi
stdout
p[0][0]=p[0][1]=p[0][2]=p[1][0]=p[1][1]=p[1][2]=p[2][0]=p[2][1]=p[2][2]=
abc
def
ghi