/*结构体 struct mpow 两个成员的意义是:a为幂的底,t为幂的指数
编写fun,计算出x所指数组中n个幂数之和并返回
例如:当结构体数组用12,0,9,2,23,1,7,2初始化时,
程序的输出结果应该是sum=154.000000*/
struct mpow
{
double a;
int t;
}
double fun(struct mpow *x,int n)
{
int i,j;
double sum=0.0,m;
for(i=0;i<n;i++)
{
m=1;
for(j=0,j<x[i].t;j++)
{
m=m*x[i].a;
}
sum+=m;
}
return sum;
}