遍历求乘积时为什么不能用区间来判定字符,而是要用字符串长度?
查看原帖
遍历求乘积时为什么不能用区间来判定字符,而是要用字符串长度?
394719
Hasci楼主2021/8/3 10:38
#include<stdio.h>
//#include<string.h>

int main(){
	char ch[7];
	int mod1=1,mod2=1;
	scanf("%s",ch);
	puts(ch);
	for(int i=0;i<7;i++){
    //这里把7换成strlen(ch)才能过
   	//为什么呀?
		if(ch[i]>='A'&&ch[i]<='Z'){
			mod1*=ch[i]-'A'+1;
		}
	}
	scanf("%s",ch);
	puts(ch);
	for(int i=0;i<7;i++){
		if(ch[i]>='A'&&ch[i]<='Z'){
			mod2*=ch[i]-'A'+1;
		}
	}
	if(mod1%47==mod2%47){
		printf("GO\n");
	}else{
		printf("STAY\n");
	}
	return 0;
}
2021/8/3 10:38
加载中...