Full permutation function:
#include<algorithm>
int array[10]={1,2,3,4,5,6,7,8,9,0}
do{
........
}while(newxt_permutation(array,array+10));
Example: Calculator_2018 Blue Bridge Cup_Analog 5_Number of Prime Numbers
#include<iostream> #include<algorithm> #include<cmath> #include<iomanip> using namespace std; bool SS(int n) {//Find the prime number (prime number) function for (int i = 2; i*i <= n;i++) {//I personally think the code is not bad! if (n%i==0) { return 0; } } return 1; } int main() { int Array[8] = { 0,1,2,3,4,5,6,7}; int account = 0; do { if (Array[7]!=0) {//The first number cannot be 0!! if (SS(Array[0] + Array[1] * 10 + Array[2] * 100 + Array[3] * 1000 + Array[4] * 10000 + Array[5] * 100000 + Array[6] * 1000000 + Array[7] * 10000000)) { account++; } } } while (next_permutation(Array,Array+8)); cout << account << endl; return 0; }
.