# 已知一个浮点数A（0<A<5），求它由哪两个整数B/C相除的值最接近

已知一个浮点数A（0<A<5），求它由哪两个整数B/C相除的值最接近，有相同值时要求B最小

例如：

```json
A=0.2
B=1 C=5
```

以下程序实现了这一功能，请你填补空白处内容：

```cpp
#include <stdio.h>
#include <math.h>
int main()
{
    float A = 0.2f;
    int x = 0;
    if (A < 0)
    {
        x = 1;
        A = 1 / A;
    }
    float delta = 1;
    int B = 1, C = 1;
    do
    {
        ____________;
    } while (delta > 0.000001);
    if (x == 0)
        printf("%d / %d", C, B - 1);
    else
        printf("%d / %d", B - 1, C);
    return 0;
}
```

## template

```cpp
#include <stdio.h>
#include <math.h>
int main()
{
    float A = 0.2f;
    int x = 0;
    if (A < 0)
    {
        x = 1;
        A = 1 / A;
    }
    float delta = 1;
    int B = 1, C = 1;
    do
    {
        C = (int)(B * A);
        delta = fabs(C / (float)B - A);
        B++;
    } while (delta > 0.000001);
    if (x == 0)
        printf("%d / %d", C, B - 1);
    else
        printf("%d / %d", B - 1, C);
    return 0;
}
```

## 答案

```cpp
C = (int)(B * A);
delta = fabs(C / (float)B - A);
B++;
```

## 选项

### A

```cpp
C = B * A;
delta = fabs(C / (float)B - A);
B++;
```

### B

```cpp
C = B * A;
delta = fabs(C / B - A);
B++;
```

### C

```cpp
C = B * A;
delta = fabs(C / (float)B - A);
B++;
```