Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- bool isEven(int n) {
- if(n%2==0) return true;
- else return false;
- }
- int digits(int n) {
- int d=1;
- while (n/10!=0) {
- n/=10;
- d++;
- }
- return d;
- }
- int midNumber(int n) {
- for (int i=(digits(n)/2);i>0;i--) n=n/10;
- return n%10;
- }
- int main() {
- int plays,A,B,result=0;
- cin>>plays;
- cin>>A;
- if (not isEven(digits(A))) {
- for (int i=(plays-1);i>0;i--) {
- cin>>B;
- if (isEven(digits(B)) or midNumber(A)!=midNumber(B)) {
- result=1;
- break;
- }
- cin>>A;
- if (isEven(digits(A)) or midNumber(A)!=midNumber(B)) {
- result=2;
- break;
- }
- }
- if (result==0) {
- cin>>B;
- if ((isEven(digits(B)) or midNumber(A)!=midNumber(B)) and result==0) result=1;
- }
- }
- else result=2;
- switch(result) {
- case 1:
- cout<<"A"<<endl;
- break;
- case 2:
- cout<<"B"<<endl;
- break;
- case 0:
- cout<<"="<<endl;
- break;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment