02_25_袁佳琪 @ 2019-07-25 10:12:49
#include<stdio.h>
int main(){
int k;
int n = 1;
float sum = 0;
scanf("%d", &k);
while (sum < k){
sum += (1.0 / n);
n = n + 1;
}
printf("%d", n);
return n;
}
by 银之匙 @ 2019-08-09 16:36:43
sum+=(1.0/n);这条语句的n前面加个(double),也就是把n转换为double类型。
by junochen1114 @ 2019-09-02 16:36:33
注意数据类型以及精度啊····