#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
#include<Windows.h>
#include<stdio.h>
#define N 5
#define M 4
int oushu(int a)
{
if (a % 2 == 0)
return 1;
else return 0;
}
int shusu(int b)
{
for (int i = 2; i < b; i++)
{
if (b%i == 0) return 0;
}
return 1;
}
void main()
{
int a[M][N] = { { 1, 2, 3, 4, 54 }, { 23, 34, 12, 43, 34 }, { 56, 76, 87, 344, 34, }, { 432, 32, 43, 54, 535 } };
int *p = &a,b[20];
int feixianglingtotal=0,k=0;
b[0] = 0;
for (int i = 0; i < N*M-1; i++)
{
if (oushu(*(p + i)) && shusu(*(p + i + 1)))
{
i++;
}
else if (i == N*M - 2)
{
b[k++] = *(p + i);
b[k++] = *(p + i + 1);
feixianglingtotal += *(p + i) + *(p + i + 1);
}
else
{
b[k
找出MXN数组中所有不相邻元素,并求出它们的和(相邻的数:前一个数是偶数,后一个数是素数)
最新推荐文章于 2023-12-09 16:01:42 发布