#include <stdio.h>
int main() {
int data[9] = {10, 15, 15, 18, 20, 20, 20, 25, 30};
int A = 15;
int B = 20;
int low,high,mid;
int resultA = 0;
int resultB = 0;
low = 0;
high = 9;
while(low < high){
mid = (low + high) / 2;
if (data[mid] >= A){
high = mid;
}else{
low = mid +1;
}
resultA = low;
}
low = 0;
high = 9;
while(low < high){
mid = (low + high) / 2;
if (data[mid] > B){
high = mid;
}else{
low = mid +1;
}
resultB = low;
}
printf("%d",resultB-resultA);
return 0;
}
To embed this project on your website, copy the following code and paste it into your website's HTML: