(C语言)买东西找零钱

#include <stdio.h>
#include <string.h>
#define N 1000
void main()
{

int x, y,sum=0;

printf("请输入小明的钱和购买物品的钱:");

scanf("%d %d", &x, &y);

x = x - y;

sum += x / 100; x = x % 100;

sum += x / 50; x = x % 50;

sum += x / 20; x = x % 20;

sum += x / 10; x = x % 10;

sum += x / 5; x = x % 5;

sum += x;

printf("应该找小明%d张零钱\n", sum);

}

posted on 2020-07-02 23:19  白胡  阅读(841)  评论(0编辑  收藏  举报

导航