全RE 求助
查看原帖
全RE 求助
260361
hanran_楼主2021/6/28 18:24

~~```cpp

#include #include <bits/stdc++.h>

using namespace std;

char _myStr[1001]; //string _number[27] = {"a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"}; int _n[27] = {0}; const int su[25] = {2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97}; int _sum = 0; int _big = 0; int _small = 0; bool _flag = false;

bool cmpd(int a,int b) { return a > b; }

void ParseIn () {

cin >> _myStr;

// cout << _myStr[0]-'a';

}

void Core () { int curseIn = 0; for (int i = 0; i < 26; i++) { _n[_myStr[i]-'a']++; }

sort(_n,_n + 26,cmpd);

_big = _n[0];

if (strlen(_myStr) > 1) {
	for (int i = 0; i < 26; i++) {
        _small = _n[i];
        if (_n[i] == 0) {
        	_small = curseIn;
		}
		curseIn = _small;
	}
}

_sum = _big - _small;

for (int i = 0; i < 25; i++) {
	if (_sum == su[i]) {
		_flag = 1;
	}
}

// for (int i = 1; i <= ) }

void CWriteOut () {

// for (int i = 0; i < 26; i++) { // cout << _n[i] << " "; // } //// cout << if (_flag) { cout << "Lucky Word"; } else { cout << "No Answer"; } cout << endl; cout << _sum;

}

int main () { ParseIn(); Core(); CWriteOut();

return 0;

}

~~
2021/6/28 18:24
加载中...