Trik
Author: Pakin Olanraktham
Source: PROGRAMMING.IN.TH
Difficulty: ?
Tags: Implementation
Prerequisites:
เฉลย
เฉลย
#include <stdio.h>
#include <string.h>
int main() {
char t[51];
scanf("%s", t);
int p = 1;
for (int i=0; i<strlen(t); i++) {
if (t[i] == 'A') {
if (p == 1) p = 2;
else if (p == 2) p = 1;
} else if (t[i] == 'B') {
if (p == 2) p = 3;
else if (p == 3) p = 2;
} else {
if (p == 1) p = 3;
else if (p == 3) p = 1;
}
}
printf("%d", p);
}