(C语言)买东西找零钱

时间:2020-07-03 01:17:32   收藏:0   阅读:120

#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);

}

评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!