Untitled
unknown
plain_text
2 years ago
1.2 kB
8
Indexable
#include <iostream>
#include <vector>
using namespace std;
int main() {
int rows = 3;
int cols = 4;
char status[3][4] = {
{'d', 'c', 'd', 'c'},
{'c', 'd', 'c', 'd'},
{'d', 'c', 'd', 'c'}
};
// Simulate the cleaning process
for (int i = 0; i < rows; i++) {
if (i % 2 == 1) {
for (int j = cols - 1; j >= 0; j--) {
if (status[i][j] == 'd') {
cout << "Clean cell at position (" << i + 1 << ", " << j + 1 << ")" << endl;
status[i][j] = 'c';
}
if (j > 0) {
cout << "Move left" << endl;
}
}
} else {
for (int j = 0; j < cols; j++) {
if (status[i][j] == 'd') {
cout << "Clean cell at position (" << i + 1 << ", " << j + 1 << ")" << endl;
status[i][j] = 'c';
}
if (j < cols - 1) {
cout << "Move right" << endl;
}
}
}
if (i < rows - 1) {
cout << "Move down" << endl;
}
}
return 0;
}
Editor is loading...