URI在线判断问题1021(纸币和硬币)答案错误

时间:2019-11-21 17:38:21

标签: c python-3.x onlinejudge

我是urionline法官的初学者问题解决者。我写了一个程序来解决问题编号1021(纸币和硬币)。我得到了100%错误的答案。我看过很多代码,但是它们只是一遍又一遍地打印。我不喜欢那样我用这种方法解决了一个较早的问题,即问题号1018(钞票)。现在,您能给我任何以这种方式解决我的问题的提示吗?

...这是我的代码...

#include <stdio.h>

int main()
{
    int i, count, note;
    int ara_notes[] = {100, 50, 20, 10, 5, 2};

    double ara_coins[] = {1.00, 0.50, 0.25, 0.10, 0.05, 0.01};
    double notes, rest_of_money, coin;

    scanf("%lf", &notes);

    rest_of_money = notes;

    printf("NOTAS:\n");
    for (i = 0; i < 6; i++)
    {
        note = ara_notes[i];
        count = rest_of_money / note;
        rest_of_money = rest_of_money - (count * note);

        printf("%d nota(s) de R$ %d.00\n", count, note);
    }

    printf("MOEDAS:\n");
    for (i = 0; i < 6; i++)
    {
        coin = ara_coins[i];
        count = rest_of_money / coin;
        rest_of_money = rest_of_money - (count * coin);

        printf("%d moeda(s) de R$ %.2lf\n", count, coin);
    }

    return 0;
}

0 个答案:

没有答案