求解哪错了

回复帖子

@Greammer 2019-11-06 16:57 回复
#include<stdio.h>
#include<string.h>
int mod(int m){
    return m%47;
}
int main()
{
    char a[27]={"ABCDEFGHIGKLMNOPQRSTUVWXYZ"};
    int num[26]={1,2,3,4,5,6,7,8,9,10,11,12,13,
    14,15,16,17,18,19,20,21,22,23,24,25,26};
    int p;
    char b[7];
    scanf("%s",&b);
    char c[7];
    scanf("%s",&c);
    int t=1;
    int i=0;
    while(b[i]!='\0'){
        for(p=0;p<27;p++){
            if(b[i]==a[p]){
                t=num[p]*t;
                break;
                }
            }i++;
        }
    int q=1;
    int n=0;
    while(c[n]!='\0'){
        for(p=0;p<27;p++){
            if(c[n]==a[p]){
                q=num[p]*q;
                break;
                }
            }n++;
        }
        t=mod(t);
        p=mod(p);
    if(t==p){
         printf("GO");}
         else{
            printf("STAY");
         }
    return 0;
}
@zxy_168 2019-11-16 09:49 回复 举报
#include <cstdio>  
#include <iostream>    
#include <cstring>
using namespace std;  
int main(){  
    int star_len;
    int group_len;
    int i,j;
    char star[7] = {'\0'};
    char group[7] = {'\0'};
    int ans_star = 1;
    int ans_group = 1;
    gets(star);
    gets(group);
    star_len = strlen(star);
    group_len = strlen(group);
    for (i = 0 ; i < star_len ; i++)
    {
        ans_star *= (star[i]-'A'+1);
    }
    ans_star = ans_star%47;
    for (j = 0 ; j < group_len ; j++)
    {
        ans_group *= (group[j]-'A'+1);
    }
    ans_group = ans_group%47;
    if (ans_star == ans_group)
    {
        printf("GO");
    }else{
        printf("STAY");
    }
    return 0;
}
反馈
如果你认为某个帖子有问题,欢迎向洛谷反馈,以帮助更多的同学。



请具体说明理由,以增加反馈的可信度。