1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
/*针对职工工资的发放,给出各种标额最少的张数的付款方案,
票额包括:100元、50元、20元、10元、5元、2元、和1元。
思路:1、设工资数为total
2、100元的张数为total/100
50元的张数为total%100/50
20元的张数为total%100%50/20
10元的张数为total%100%50%20/10
5元 total%100%50%20/5
2元 total%100%50%20%5/2
1元 total%100%50%20%5%2/1
*/
#include <iostream>
using
namespace
std;
int
main()
{
int
total;
cout<<
"输入工资:"
<<endl;
cin>>total;
int
t_100=total/100;
int
t_50=total%100/50;
int
t_20=total%100%50/20;
int
t_10=total%100%50%20/10;
int
t_5=total%100%50%20/5;
int
t_2=total%100%50%20%5/2;
int
t_1=total%100%50%20%5%2/1;
cout<<
"total="
<<t_100<<
"*100"
<<
"+"
<<t_50<<
"*50"
<<
"+"
<<t_20<<
"*20"
<<
"+"
<<t_10<<
"*10"
<<
"+"
<<t_5<<
"*5"
<<
"+"
<<t_2<<
"*2"
<<
"+"
<<t_1<<
"*1"
<<endl;
return
0;
}
|