40分求助
查看原帖
40分求助
1636444
ininred楼主2025/1/20 22:14
include<stdio.h>
int main()
{
	int k;
	int n;
	int i;
	float sum1=0,sum2=0;
	int sum11=0,sum22=0;
	scanf("%d %d",&n,&k);
	for(i=1;i<=n;i++)
	{
	    if(i%k==0)
		{
		   sum1+=i;
		   sum11++;
		}
		else 
		{
		    sum2+=i;
		    sum22++;
		}
	}
	sum1=sum1/sum11;
	sum2=sum2/sum22;
	printf("%.1f %.1f",sum1,sum2);
	return 0;
}
2025/1/20 22:14
加载中...