-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathA_Distinct_Buttons.cpp
More file actions
44 lines (34 loc) · 873 Bytes
/
A_Distinct_Buttons.cpp
File metadata and controls
44 lines (34 loc) · 873 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#include <iostream>
#include <cmath>
using namespace std;
void visitSpecialPoints(int n, int specialPoints[][2]) {
for (int i = 0; i < n; ++i) {
int xi = specialPoints[i][0];
int yi = specialPoints[i][1];
// Move right
for (int j = 0; j < abs(xi); ++j) {
cout << "R";
}
// Move left
for (int j = 0; j < abs(xi); ++j) {
cout << "L";
}
// Move up
for (int j = 0; j < abs(yi); ++j) {
cout << "U";
}
// Move down
for (int j = 0; j < abs(yi); ++j) {
cout << "D";
}
cout << endl;
}
}
int main() {
// Example with 3 special points
int n = 3;
int specialPoints[3][2] = {{1, -1}, {0, 0}, {1, -1}};
// Visit special points
visitSpecialPoints(n, specialPoints);
return 0;
}