Home > Back-end >  For help
For help

Time:09-17

Write - a program to define a 2 d array int rryl {1, 2, 3, 4, 9,10,11,121 {} {, June} respectively output of all the prime Numbers, and to all the prime Numbers and the average
To the output, (prime Numbers: in a natural number greater than 1, besides 1 and itself, there will be no other factor)

CodePudding user response:

 # include & lt; Bits/stdc++. H> 
using namespace std;

Int rryl [3] [4]={{1, 2, 3, 4}, {5,6,7,8}, {9,10,11,12}};

Bool isprime (int a) {
For (int I=2; iIf I==0) (a % {
return false;
}
}
return true;
}

Int main () {
Int CNT=0;
Double sum=0;
Double pj.//the mean
for(int i=0; i<3; + + I) {
for(int j=0; j<4. + + j) {
If (isprime (rryl [I] [j])) {
The sum +=rryl [I] [j];
+ + CNT;
Cout & lt; }
}
}
Pj=sum/CNT;
Cout & lt; Cout & lt; Cout & lt; return 0;
}
  • Related