zoj 2772 Quick Change(水~)

    技术2023-03-29  19

    给你钱数,让你换成多少quarters ($0.25), dimes ($0.10), nickels ($0.05) and pennies ($0.01) 

     

    if the change due back is $1.24, the customer should receive 4 quarters, 2 dimes, 0 nickels, and 4 pennies.

     

    #include <stdio.h> #include <stdlib.h> #include <iostream> #include <string.h> using namespace std; int main() { int n,ncases,ind = 1,x,y,z; scanf("%d",&ncases); while( ncases-- ) { scanf("%d",&n); x = n/25; n -= x*25; y = n/10; n -= y*10; z = n/5; n -= z*5; printf("%d %d QUARTER(S), %d DIME(S), %d NICKEL(S), %d PENNY(S)/n",ind++,x,y,z,n); } return 0; }  

    最新回复(0)