求助(必关)
请各位高手看看为什么运行不了(必关)
#include<bits/stdc++.h>
using namespace std;
const int MAXN = 100;
bool Prime_Number_Judge(const int &num) {
if (num <= 3)
return num > 1;
for (int i = 2; i < num; i++)
if (num % i == 0)
return false;
return true;
}
int& Get_Number_Size(const int &num) {
int digit = 0, val = num;
while (val) {
val /= 10;
digit++;
}
return digit;
}
vector<int>&Get_Digits(const int &num, vector<int> &digits) {
int vactor_val = 0;
for (int num_size = Get_Number_Size(num); num_size > 0; num_size--) {
vactor_val = num % (int)pow(10.0, num_size);
vactor_val = vactor_val / (int)pow(10.0, num_size - 1);
digits.push_back(vactor_val);
}
return digits;
}
vector<int>&Get_K_Adjacent(const int &num, vector<int>&adjacent) {
vector<int> digists_number;
char tmp[128], buf_tmp[128];
Get_Digits(num, digists_number);
int digits = Get_Number_Size(num);
for (int i = 0; i < digits; i++) {
for (int j = 0; j < digits - i; j++) {
string buf;
int k = 0;
while (k <= i) {
sprintf(tmp, "%d", digists_number.at(j + k));
buf += tmp;
k++;
}
for (int i = 0; i <= buf.size(); i++)
buf_tmp[i] = buf[i];
adjacent.push_back(atoi(buf_tmp));
}
}
return adjacent;
}
int main() {
int count = 0;
for (int i = 1; i < MAXN; i++) {
if (Prime_Number_Judge(i)) {
vector<int> buf;
Get_K_Adjacent(i, buf);
int sign = 1;
for (int j = 0; j < buf.size(); j++) {
if (!Prime_Number_Judge(buf.at(j))) {
sign = 0;
break;
}
}
if (sign)
count++;
}
}
cout << count;
return 0;
}
意见放评论区Thanks♪(・ω・)ノ