fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int main() {
  5. int baris, kolom;
  6. bool masihsatu = true;
  7. cin >> baris >> kolom;
  8.  
  9. vector<vector<int>> kotak(baris, vector<int>(kolom));
  10. for (int a = 0; a < baris; a++) {
  11. for (int b = 0; b < kolom; b++) {
  12. char input;
  13. cin >> input;
  14. kotak[a][b] = input - '0';
  15.  
  16. if (masihsatu && kotak[a][b] == 0) {
  17. masihsatu = false;
  18. }
  19.  
  20. }
  21.  
  22. if (masihsatu && a > baris) {
  23. for (int c = 0; c < kolom; c++) {
  24. kotak[a - 1][c] = 0;
  25. }
  26. }
  27. masihsatu = true;
  28.  
  29. }
  30.  
  31. for (int a = 0; a < baris; a++) {
  32. for (int b = 0; b < kolom; b++) {
  33. cout << kotak[a][b];
  34. }
  35. cout << endl;
  36. }
  37.  
  38. }
Success #stdin #stdout 0.01s 5324KB
stdin
3 3
111
111
111
stdout
111
111
111