# 约分

编写程序，要求用户输入一个分数，然后将其约分为最简式。如：

输入一个分数：8/12

最简分式：2/3

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

```cpp
#include <stdio.h>
#include <stdlib.h>
int main()
{
    int a, b, x, y, c;
    printf("输入一个分式：");
    scanf("%d/%d", &a, &b);
    _________________;
    while (c)
    {
        x = y;
        y = c;
        c = x % y;
    }
    if (b / y != 1)
        printf("最简分式为：%d/%d", a / y, b / y);
    else
        printf("最简分式为：%d", a / y);
    return 0;
}
```

## template

```cpp
#include <stdio.h>
#include <stdlib.h>
int main()
{
    int a, b, x, y, c;
    printf("输入一个分式：");
    scanf("%d/%d", &a, &b);
    if (a < b)
    {
        x = b;
        y = a;
    }
    else
    {
        x = a;
        y = b;
    }
    c = x % y;
    while (c)
    {
        x = y;
        y = c;
        c = x % y;
    }
    if (b / y != 1)
        printf("最简分式为：%d/%d", a / y, b / y);
    else
        printf("最简分式为：%d", a / y);
    return 0;
}
```

## 答案

```cpp
if (a < b)
{
	x = b;
	y = a;
}
else
{
	x = a;
	y = b;
}
c = x % y;
```

## 选项

### A

```cpp
if (a < b)
{
	x = a;
	y = b;
}
else
{
	x = b;
	y = a;
}
c = x % y;
```

### B

```cpp
if (a < b)
{
	x = a;
	y = b;
}
else
{
	x = b;
	y = a;
}
c = x / y;
```

### C

```cpp
if (a < b)
{
	x = b;
	y = a;
}
else
{
	x = a;
	y = b;
}
c = x / y;
```