---
# System prepended metadata

title: 21-6 算浮點數餘數
tags: [DICE C]

---

---
tags: DICE C
---

21-6 算浮點數餘數
===

> [name=CHAWTeam]

目錄：[DICE C語言程式破解](/@CHAWTeam/DiceC)

題目
---

```!
輸入第一個整數，代表測試資料筆數，
接下來每行輸入兩個浮點數，使用數學函數fmod求浮點餘數。

輸入範例:
5
5.33 2.33
13.657 2.333
8.33 1.3
8.3 4.2
95.3 4.33

輸出範例:
0.670000
1.992000
0.530000
4.100000
0.040000
```

程式碼
---

```c=
#include <stdio.h>
#include <math.h>

int main()
{
    float n, x, y;
    scanf("%f", &n);
    
    for (int i = 0; i < n; i++)
    {
        scanf("%f %f", &x, &y);
        printf("%f\n", fmod(x, y));
        
    }
    return 0;
}
```

執行
---

### 輸入

```!
5
5.33 2.33
13.657 2.333
8.33 1.3
8.3 4.2
95.3 4.33
```

### 輸出

```!
0.670000
1.992000
0.530000
4.100000
0.040000
```

---

[查看我們在HackMD上的所有筆記](/@CHAWTeam)
目錄：[DICE C語言程式破解](/@CHAWTeam/DiceC)

---

{%hackmd Iiu5mOixR7yWkPHKCkabBg %}
<iframe class="LikeCoin" height="235" src="https://button.like.co/in/embed/chawteam/button?referrer=https://hackmd.io/@CHAWTeam/DiceC-21-6" width="100%"></iframe>

---

{%hackmd i1nMRrZcTFmTvoF897K9zg %}