为什么输出结果不对?是哪里出错了?

图片说明图片说明

#include <stdio.h>
#include <stdlib.h>
//洛谷1200// 
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
#define N 8
int main(int argc, char *argv[]) {
    char a[N],b[N];
    int i=0,s1=1,s2=1;
    while(getchar()!='\n')
    {
        scanf("%c",&a[i]);
        s1*=(a[i++]-'A'+1);
    }
    i=0;
    while(getchar()!='\n')
    {
        scanf("%c",&b[i]);
        s2*=(b[i++]-'A'+1);
    }
    if((s1%47)==(s2%47))
    {
        printf("GO");
    }
    else
        printf("STAY");
    return 0;
}
    char a[8]{}, b[8]{};
    int i = 0, s1 = 1, s2 = 1;
    while (scanf_s("%c", &a[i]))
    {
        s1 *= (a[i++] - 'A' + 1);
        if (a[i-1] == '\n')break;
    }
    i = 0;
    while (scanf_s("%c", &b[i]))
    {
        s2 *= (b[i++] - 'A' + 1);
        if (b[i-1] == '\n')break;
    }
    if ((s1 % 47) == (s2 % 47))
        printf("GO");
    else
        printf("STAY");

图片说明