For Problem 2#include <cstdlib>#include <iostream>using namespace std;int main(int argc, char *argv[]){ int money, temp, mh, mm, mt, mf, md; money = 1000; temp = money - 1;//用掉一元,可找回最多餘額 mh = temp/100; temp = temp - mh*100; mm = temp/50; temp = temp - mm*50; mt = temp/10; temp = temp - mt*10; mf = temp/5; temp = temp - mf*5; md = temp; cout << "使用1000元購物,可找回" <<endl; cout << "100元紙鈔最多 " << mh << " 張" <<endl; cout << "50元硬幣最多 " << mm << " 個" <<endl; cout << "10元硬幣最多 " << mt << " 個" <<endl; cout << "5元硬幣最多 " << mf << " 個" <<endl; cout << "1元硬幣最多 " << md << " 個" <<endl; system("PAUSE"); return EXIT_SUCCESS;} .msgcontent .wsharing ul li { text-indent: 0; } 分享 Facebook Plurk YAHOO! .
- Jan 17 Tue 2012 22:49
For Problem 2
close
全站熱搜
留言列表
禁止留言