<分区>
问题:
Your task is to:
Write a function that prints to the standard output (stdout) the number of users who didn't leave the site after 10 seconds (i.e: the number of users who didn't bounce).
Please round the result downwards to the nearest integer (e.g both
7.1
and7.9
are rounded to7
).Note that your function will receive the following arguments:
n
which is an integer representing the number of visitors
b
which is an integer representing the bounce rate (i.e: the percentage of users who left the site in the first 10 seconds)
我的代码编译得很好,我很确定我的逻辑是正确的,但我的输出是错误的,我不知道为什么。当 n = 1000
和 b = 25
时,我的结果应该是 750
。我不断获得 1000
。我哪里错了?
我也不确定如何按照他们希望我的方式“舍入”。这也可能是我没有得到正确输出的原因吗?
我的代码:
void compute_active_users(int n, int b) {
int BounceConvert = (b / 100); //converts the value of b to a decimal
int BounceRate = (n * BounceConvert); // multiplys n times the b decimal
int TotalVisitors = (n - BounceRate); // subtract BounceRate
printf("%d", TotalVisitors); // print out the final result
}