帮忙看看哪里的问题
查看原帖
帮忙看看哪里的问题
1391906
ljz329楼主2024/8/20 22:16
#include<bits/stdc++.h>
using namespace std;
int Max = -1,Min = 200,s1 = 0;
char b[110];
bool sus(int x){
    if(x == 2 || x == 3){
        return 1;
    }if(x == 0 || x == 1){
        return 0;
    }
    for(int i = 2;i <= x;i++){
        if(x % i == 0){
            return 0;
        }
    }
    return 1;
}
int main(){
    scanf("%s",b);
    int l = strlen(b);
    for(int i = 1;i <= l;i++){
        for(int j = 1;j <= l;j++){
            if(b[j] == b[i]) s1++;
        }
        if(s1 > Max) Max = s1;
        if(s1 < Min) Min = s1;
        s1 = 0;
    }
    int s = Max - Min;
    if(sus(s)){
        cout << "Lucky Word" << endl << s;
    }else{
        cout << "No Answer" << endl << "0";
    }
    return 0;
}
2024/8/20 22:16
加载中...