针对职工工资的发放,给出各种票额钞票(包伙:100元,50元,20元,10元,5元,1元)最少张数的付款方案。
展开全部
#include <iostream>
using namespace std;
int main()
{
int salary;
int n100 = 0,n50= 0,n20=0,n10=0,n5=0,n1=0;
cout<<"Input the salary count:"<<endl;
cin>>salary;
n100 = salary/100;
salary %= 100;
n50 = salary/50;
salary %= 50;
n20 = salary/20;
salary %= 20;
n10 = salary/10;
salary %= 10;
n5 = salary/5;
salary %= 5;
n1 = salary;
cout<<"100 yuan count: "<<n100<<endl;
cout<<"50 yuan count: "<<n50<<endl;
cout<<"20 yuan count: "<<n20<<endl;
cout<<"10 yuan count: "<<n10<<endl;
cout<<"5 yuan count: "<<n5<<endl;
cout<<"1 yuan count: "<<n1<<endl;
system("pause");
return 0;
}
using namespace std;
int main()
{
int salary;
int n100 = 0,n50= 0,n20=0,n10=0,n5=0,n1=0;
cout<<"Input the salary count:"<<endl;
cin>>salary;
n100 = salary/100;
salary %= 100;
n50 = salary/50;
salary %= 50;
n20 = salary/20;
salary %= 20;
n10 = salary/10;
salary %= 10;
n5 = salary/5;
salary %= 5;
n1 = salary;
cout<<"100 yuan count: "<<n100<<endl;
cout<<"50 yuan count: "<<n50<<endl;
cout<<"20 yuan count: "<<n20<<endl;
cout<<"10 yuan count: "<<n10<<endl;
cout<<"5 yuan count: "<<n5<<endl;
cout<<"1 yuan count: "<<n1<<endl;
system("pause");
return 0;
}
展开全部
void Count(int n)
{
int memony[] = {100, 50, 20, 10, 5, 1};
int num[6] = {0};//存储所需钱的张数
int tmp = n ;
for(int i = 0; i < sizeof(memony); i++)
{
if(tmp >= memony[i] && tmp / memony[i] >= 0)
{
num[i] = tmp / memony[i];
tmp = tmp % memony[i];
}
}
}
{
int memony[] = {100, 50, 20, 10, 5, 1};
int num[6] = {0};//存储所需钱的张数
int tmp = n ;
for(int i = 0; i < sizeof(memony); i++)
{
if(tmp >= memony[i] && tmp / memony[i] >= 0)
{
num[i] = tmp / memony[i];
tmp = tmp % memony[i];
}
}
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询