Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

29020 755200 游城棣 錢包問題 #19

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions 755200/29020 755200 游城棣 錢包問題.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#include <iostream>
using namespace std;
int main() {
double moneydot;
int bill, money;
do
{
cout << "金額:" ;
cin >> moneydot;
moneydot = moneydot * 10;
} while (moneydot != (int)moneydot);
for (money = moneydot; money > 10000; money -= 10000) {
bill ++;
}
for (money = money; money > 5000; money -= 5000) {
bill ++;
}
for (money = money; money > 1000; money -= 1000) {
bill ++;
}
for (money = money; money > 500; money -= 500) {
bill ++;
}
for (money = money; money > 100; money -= 100) {
bill ++;
}
for (money = money; money > 50; money -= 50) {
bill ++;
}
for (money = money; money > 10; money -= 100) {
bill ++;
}
for (money = money; money > 5; money -= 5){
bill ++;
}
for (money = money; money > 1; money -= 1){
bill ++;
}
cout << "最少需要:" << bill << "枚銅板或紙鈔";
}