interestingsoul @ 2023-09-24 21:44:12
#include <stdio.h>
#include <stdlib.h>
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
int main(int argc, char *argv[]) {
float sum1,sum2;
int n1,n2,k,n;
scanf("%d %d",&n,&k);
for(int i=1;i<=n;i++){
if(i%k==0){
sum1+=i;
n1++;
}
else{
sum2+=i;
n2++;
}
}
printf("%.1f ",sum1/n1);
printf("%.1f",sum2/n2);
return 0;
}
by cloudins @ 2023-10-05 12:39:38
我也是这样,我现在正在研究
by cloudins @ 2023-10-05 12:49:56
n1 n2 初始化试试
by witherbogged @ 2023-11-01 21:03:50
n1和n2要初始化为0