Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void main()
- {
- int k = 9; // 9 code
- int n = 60; // 60 student
- int p = 1;
- int q = 2;
- int locA = p * 2 + q - 1; // location of A
- int locB = (locA > k ? locA - k : (locA + k > n ? locA + k : -1)); // location of B, -1 if invalid
- if (locB == -1) { cout << "Location not found (-1)" << endl; return; }
- int code = (locA > k ? locA % k : locA); // B need to match this code
- cout << "Code needed to be matched: " << code << endl;
- int v = locB % 2 + 1;
- int u = (locB - v) / 2;
- cout << "B is need to be at row: " << u << " position: " << v << endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement