0f分求助C++
查看原帖
0f分求助C++
845879
yawningking楼主2023/2/25 10:28
#include<iostream>
#include<algorithm>
#include<cmath>
#include<string>
#include<iomanip>
using namespace std;
int main() {
    string a;
    cin >> a;
    int ans=0;
    int b[120] = { 0 };
    for (int i = 0; i < a.length(); i++) {
        int ans = 0;
        for (int j = 0; j < a.length(); j++) {
            if (a[i] == a[j]) {
                ans++;
                if (j == a.length() - 1) {
                    b[i] = ans;
                }
            }
        }
}
    sort(b, b + 120);
    int x = b[119] - b[119 - a.length()];
    for (int i = 2; i < x; i++) {
        if (x == 0) {
            goto L;
        }
        if (x == 1) {
            goto L;
        }
        else  if (x % i == 0) {
        L:
            cout << "No Answer" << endl;
            cout << "0";
            break;
        }
        else cout << "Lucky Word" << endl;
        cout << x;
    }

    return 0;
}
2023/2/25 10:28
加载中...