#include
#include
#include
int calc(double *pdResult)
{
int a[5][5] = {{23, 45, 56, 13, 34},
{34, 74, 85, 54, 76},
{56, 98, 56, 76, 67},
{98, 54, 83, 12, 59},
{33, 87, 74, 48, 62}};
int b[3][4] = {{11, 52, 67, 25},
{45, 54, 69, 89},
{96, 68, 79, 86}};
double pa = 0.0;
double pb = 0.0;
double result = 0.0;
int i = 0;
int j = 0;
for(i =0; i <= 4; i++)
{
for(j = 0; j <= 4; j++)
{
if(a[i][j] % 2 == 0)
{
pa += sqrt((double)a[i][j]);
}
}
}
for(i = 0; i <= 2; i++)
{
for(j = 0; j <= 3; j++)
{
if(b[i][j] % 2 == 0)
{
pb += sqrt((double)b[i][j]);
}
}
}
*pdResult = pa + pb;
return 0;
}
int main(int argc, char **argv)
{
int iRet = 0;
double dResult = 0.0;
iRet = calc(&dResult);
printf("PA+PB=%.5lf", dResult);
return 0;
}
编译通过,测试通过
不懂帮顶
干啥用的