绿野仙踪 @ 2020-12-12 10:03:27
#include<stdio.h>
int main()
{
int *p,y1=0,y2=0,data[1000],i,n,k,count=0;
double average1,average2;
p=data;
scanf("%d%d",&n,&k);
for(i=0;i<n;i++)
{
*(p+i)=i+1;
}
for(p=data;p<&data[n];p++)
{
if(*p%k==0)
{
count++;
y1+=*p;
}
else
{
y2+=*p;
}
}
average1=y1*1.0/count;
average2=y2*1.0/(n-count);
printf("%.1lf %.1lf",average1,average2);
return 0;
}
by Wildcxj @ 2020-12-12 10:08:27
如果深基过不去就肯定不叫大佬。
by w23c3c3 @ 2020-12-12 10:09:45
咋就用地址指针了呢,不会啊
数组开到11000试试看
by CGDGAD @ 2020-12-12 10:21:42
数组开得太小。