60分求教
查看原帖
60分求教
1494443
wdmzjhyk楼主2024/12/2 09:19
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include<string.h>
#include<iostream>
#include<algorithm>
using namespace std;
bool zhishu(int n) {
	if (n <= 1) {
		return false;
	}
	for (int j = 2; j * j <= n; j++) {
		if (n % j == 0) {
			return false;
		}
	}
	return true;
}
int main()
{
	char str[1001];
	int s[1001] = { 0 };
	int s1[1001] = { 0 };
	int b = 0, a = 0, c = 0;
	scanf("%s", str);
	for (int i = 0; i < strlen(str); i++) {
		s1[str[i]]++;
	}
	for (int i = 0; i < 256; i++) {
		if (s1[i] > 0) {
			s[c++] = s1[i];
		}
	}
	sort(s, s + c);
	int zhi = s[c - 1] - s[0];
	if (bool(zhi) == true)
	{
		printf("Lucky Word\n");
		printf("%d", zhi);
	}
	else
	{
		printf("No Answer\n");
		printf("0");
	}
	return 0;
}
2024/12/2 09:19
加载中...