#include<stdio.h> #include<string.h> int main() { char arr[10000] = ""; gets(arr); int len = strlen(arr); int x = 0; int y = 0; for (int i = 0; i < len-1; i++) { if((i == 0||arr[i-1]==';')&&(arr[i]=='A'||arr[i]=='D'||arr[i]=='W'||arr[i]== 'S')) { int upper = arr[i]; i++; int l = 0; while (arr[i] >= '0' && arr[i] <= '9') { l = l * 10 + arr[i] - '0'; i++; } if (arr[i] != ';') continue; switch (upper) { case 'A': x -= l; break; case 'D': x += l; break; case 'W': y += l; break; case 'S': y -= l; break; } } } printf("%d,%d", x, y); return 0; }