此题描述很长但很水,zzj讲得很详细
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
int n,m,ans=0;
int main()
{
int i,tmp;
#ifndef ONLINE_JUDGE
freopen("sgu163.in","r",stdin);
freopen("sgu163.out","w",stdout);
#endif
scanf("%d%d",&n,&m);
for(i=1;i<=n;i++)
{
scanf("%d",&tmp);
tmp=pow(tmp,m);
if(tmp>0)
{
ans+=tmp;
}
}
printf("%d",ans);
#ifndef ONLINE_JUDGE
fclose(stdin);
fclose(stdout);
#endif
return 0;
}
本文介绍了一道使用C语言解决的编程题目,主要内容为读取一系列整数并计算每个整数的m次幂,如果结果大于0则累加到总和中,最后输出总和。代码使用了标准输入输出函数,以及pow函数进行幂运算。

被折叠的 条评论
为什么被折叠?



