硬币能构成的币值
有30个2分硬币和8个5分硬币,用这些硬币能构成的1分到1元之间的币值有多少种? #include<stdio.h>int main()
{
int i, j, k = 0, m2, m5, temp, m = { 0 }, count = 0;
for (i = 0;i <= 8;i++)
{
m5 = 5 * i;
for (j = 0;j <= 30;j++)
{
m2 = 2 * j;
m = m5 + m2;
k++;
}
}
for (i = 0;i <= k;i++)
{
for (j = 0;j <= k - 1;j++)
{
if (m > m)
{
temp = m;
m = m;
m = temp;
}
}
}
for (i = 0;i < k;i++)
{
if(m != 0 && m <= 100 && m != m)
printf("%2d ", m);
count++;
}
printf("\n");
} 风过无痕1989 发表于 2020-12-19 23:48
哇,神速啊。谢谢了~~ 乐乐学编程 发表于 2020-12-19 23:54
哇,神速啊。谢谢了~~
都是以前回答过的帖子,就花了点找帖子的时间
页:
[1]