fork(1) download
  1. #include <iostream>
  2. #include <cstdio>
  3. using namespace std;
  4.  
  5. const int maxN = 100; // change this to your liking
  6.  
  7. int n, m;
  8. char mat[maxN][maxN];
  9.  
  10. void read(int& x) {
  11. char ch = getchar_unlocked();
  12. x = 0;
  13. while (!isdigit(ch)) ch = getchar_unlocked();
  14. while (isdigit(ch)) {
  15. x = x * 10 + ch - '0';
  16. ch = getchar_unlocked();
  17. }
  18. }
  19.  
  20. int main() {
  21. read(n);
  22. read(m); //n , m sizes of matrice
  23. //note that you CAN'T use any other input method here
  24.  
  25. char ch;
  26. //ch = getchar_unlocked();
  27. //uncomment the above line if compiling on windows
  28.  
  29. for (int i = 0; i < n; i++) {
  30. for (int j = 0; j < m; j++) {
  31. mat[i][j] = getchar_unlocked();
  32. }
  33.  
  34. ch = getchar_unlocked();
  35. //ch = getchar_unlocked();
  36. //uncomment the above line if compiling on windows
  37. }
  38.  
  39. //testing to see if it works, you can delete this
  40. for (int i = 0; i < n; i++) {
  41. for (int j = 0; j < m; j++) {
  42. cout << mat[i][j];
  43. }
  44. cout << endl;
  45. }
  46. return 0;
  47. }
Success #stdin #stdout 0s 3352KB
stdin
5 3
aaa
bbb
ccc
ddd
lol
stdout
aaa
bbb
ccc
ddd
lol