View code
//// Main. M // money /// enter a specified amount (in Yuan, for example, 345.78) from the keyboard, and then display the number of different denominations that pay the amount, required to display 100 yuan, 50 yuan, 10 yuan, 5 yuan, 2 yuan, 1 yuan, 5 cents, 1 cent, 5 points, 1 cent each how many sheets // created HAN Jun on 13-2-15. // copyright (c) 2013 HAN Jun. all rights reserved. // # import <Foundation/Foundation. h> int main (INT argc, const char * argv []) {@ autoreleasepool {double money = 0.0; printf ("Enter your money :"); scanf ("% lf", & money); printf ("Your money is: % lf \ n", money); int I1 = 0, I2 = 0, i3 = 0, I4 = 0, I5 = 0, I6 = 0, i7 = 0, i8 = 0, I9 = 0, I10 = 0; while (money> 100.0) {I1 ++; money-= 100.0 ;}while (money> 50.0) {I2 ++; money-= 50.0 ;}while (money> 10.0) {I3 ++; money-= 10.0;} while (money> 5.0) {I4 ++; money-= 5.0;} while (money> 2.0) {I5 ++; money-= 2.0 ;} while (money> 1.0) {I6 ++; money-= 1.0 ;}while (money>. 5) {i7 ++; money-=. 5;} while (money>. 1) {i8 ++; money-=. 1;} while (money>. 05) {I9 ++; money-=. 05;} while (money>. 01) {I10 ++; money-=. 01;} printf ("% d, % d \ n ", i1, I2, I3, I4, I5, I6, i7, i8, I9, I10);} return 0 ;}