码迷,mamicode.com
首页 > 编程语言 > 详细

C语言之找零钱

时间:2016-08-03 19:54:09      阅读:166      评论:0      收藏:0      [点我收藏+]

标签:

#include<stdio.h>
int main()
{
int one,tow,five,num=1;
for (one = 1; one < num*10; one++)
{
for (tow = 1; tow < num*10 / 2; tow++)
{
for (five = 1; five < num*10 / 5; five++)
{
if (one + tow * 2 + five * 5 == num*10)
{
printf("可以用%d个1角+%d个2角+%d个5角得到%d元\n",one,tow,five,num);
//goto out;
}
}
}
}
//out:
return 0;
}

C语言之找零钱

标签:

原文地址:http://www.cnblogs.com/gcter/p/5734074.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!