5 like 0 dislike
14k views

Write a program that input a New Taiwan Dollar amount and then shows how to pay that amount using the small bills of $1000, $500, $100, $50, $10, $5 and $1.

將台幣現鈔換成1000, 500, 100, 50, 10, 1 元零錢

Example input:

763

Example output:

NT$1000 bills:0
NT$500 bills:1
NT$100 bills:2
NT$50 bills:1
NT$10 bills:1
NT$5 bills:0
NT$1 bills:3

Hint: Divide the amount by 1000 to determine the number of $1000 bills needed, and then reduce the amount by the total value of the $1000 bills. Repeat for the other bills sizes. Be sure to use integer values throughout, not floating-point numbers.

[Exercise] Coding (C) - asked in Chapter 4: Expressions by (12.1k points)
ID: 25731 - Available when: Unlimited - Due to: Unlimited

reshown by | 14k views

69 Answers

0 like 0 dislike
Hidden content!
#include <stdio.h>

int main(void)

{


*** *** ** ** x,a,b,c,d,e,f,g;
** * * *** * *** ***** ** * * * *
*** * ** * * * *
** * * * * **
*** **** **** * * *
** * * * ** **** * * *
** * * * ***** **** * ** **
*** *** ** *** ** ** **** *
* *** ** ** * * *******
**** **** ** * ** **** bills:%d\n",a);
* * * * * * * * * * * bills:%d\n",b);
** * * * * ** ** * * * ****
** * * ** * * * * *** *
* * * * * * *** ***** **
* ** *** * *** ** * * ** ** bills:%d\n",f);
**** * ** ** ** * * *** * bills:%d",g);
*** * * * *** 0;

}
answered by (-196 points)
0 like 0 dislike
Hidden content!
* ***** *******

int * ** *

int * * *

{

scanf ****** * * ** * ***
****** * ** *
** **

b=b+1;

}
*** * *** * * * *** **
** *** ***
***

c=c+1;

}
* ** ** ****** *** *****
*** ******
**

d=d+1;

}
* * * ** * * * ****** * * **
* * * * ** *

a=a-50;

e=e+1;

}
* * ** * ** * ** ***
* ** ** *
* *

f=f+1;

}
***** * ** * * * ***** *
** * **

a=a-5;

g=g+1;

}
********* ** *** ***** * *
* * ** **

a=a-1;

h=h+1;

}
* ** * * ** * * **** **** **

}
answered by (-336 points)
0 like 0 dislike
Hidden content!
***** ** ***** * **

int * * * * * ****

int *

{

scanf * * * * *** *
* * ******
* * *

b=b+1;

}
** * ***** **** *** * ** ** *
*** *
* ** *

c=c+1;

}
* * * * ** ** * ** * **
* *** *
*** *

d=d+1;

}
** ** ** * * * ****
**** * ** *** *

a=a-50;

e=e+1;

}
* **** *** * *** * *
* * *** **
* **

f=f+1;

}
* ** ** * **** * * *** * *
**

a=a-5;

g=g+1;

}
* ******* *** * * ** ** * *
*** * * **

a=a-1;

h=h+1;

}
* * ** ** * * *** ***

}
answered by (-336 points)
0 like 0 dislike
Hidden content!
#include <stdio.h>

#include <stdlib.h>



int main()

{

    int a;
*** * ** *** *** * * **** * ** * * * **** **
* ** ***** * * * * * * * *** * * * *
******** **** * ** ** * *** **** * * * * * * ** **** * ** * * bills:%d\n",a/1000);
***** * * * *** *** *
* * * *** ** * ** * *** * * *** ***** ** ***** * bills:0\n");


*** ** *** * * **** * ** * * ***
*** ** *** ** * * ** * *** * ** * ** * * ** ****** * bills:%d\n",a%1000/500);
** ** * * * **** *
* ** *** ** * * * ** ******* ** ** * ** **** ** ** *** bills:0\n");


*** * ****** * * * * *
* *** ** * * ** *** ***** *** ******* ** **** * ** * * ** * bills:%d\n",a%500/100);
** ****** * * * **
** ****** * * *** ***** ** * * **** * * * * * * * bills:0\n");


*** * * ****** * ** ** **
*** ******* ** * ** ******* *** *** * **** * * * ****** bills:%d\n",a%1000%100/50);
** * * * * ** ** *
** * ** * * * **** ** * * * * *** ** ** * * * **** bills:0\n");


** * ** ** * *** **** *
** ** * *** * ** ** *** * ** * * ** * ** ** ** * bills:%d\n",a%50/10);
* ******** * *****
*** * *** ** *** * *** * ******* ** * ** ** *** ** * ** * bills:0\n");


**** ** * * * ** * * * * **
* ******* ** ***** *** * ** * * ********** * * * bills:%d\n",a%10/5);
* *** * ***
*** * * * ** ***** ** * * * **** * * *** * ******* * bills:0\n");


* **** * * * * * * * **** * * *
*** * ** * * * **** * * * ** ** * * * * **** * *** * bills:%d\n",a%5/1);
** ***** *** *** *******
* ** * * * ** ** **** ** * ** * ** ** * ***** * * ** ** bills:0\n");
* * *** * * * *** ** 0;

}
answered by (-258 points)
0 like 0 dislike
Hidden content!
#include <stdio.h>

#include <stdlib.h>



int main()

{
* ** * ***** * * ** a;
* *** ** ** * * ** * ** * *** * ** **** *
** ** ***** ** *** *** * * **
* * * ** * * * * * * * * * *** * ** * ** *** * * * **** bills:%d\n",a/1000);
* * * ** *** ** *
* *** * *** * * * ** *** * * *** ** * ** * ** **** *** bills:0\n");


**** ** * * ** * ** ****** ** **** *
* * ** ****** ** * *** * ****** * * * * ** * * bills:%d\n",a%1000/500);
***** * * ** * *** **
* **** **** * ** *** * * ** ** * * ** **** ** bills:0\n");


* ** ** * * ** *** * * * **** *
*** * * ** * * ******* * ** ** * * * * * ** **** *** bills:%d\n",a%500/100);
* ** ** **** * ** ***
* * * * * **** * * * *** ** ** ** * ** ******* * bills:0\n");


* ** **** * * ******* * *
*** * * * * * ***** * ** * * * * * * * ** **** ** bills:%d\n",a%1000%100/50);
* ** **** ** ** * *
**** * ** * *** ** ** *** * * ** * * *** * * * bills:0\n");


* ******* * ** ***** * *** *** *
**** **** ** * * ** * * ** * * * * ** **** * * * bills:%d\n",(a%1000%100-50)/10);
* ** *** * ** ***** *** **
*** * * ** *** *** * *** *** * * * *** * ** *** bills:0\n");


** * ** * *** **** ****
* ** ** ** * * ***** ** * * * * * * * ** * * *** * * * bills:%d\n",a%1000%100%10/5);
*** * * * * **** * *
* * ** ****** * * * * * * * * * ** * *** ** bills:0\n");


**** * ** * * * ****** ***
* * * * ** * *** ** * ** *** ** ****** ** *** * ** bills:%d\n",a%1000%100%10%5/1);
* * **** * * ** **
** *** ** * * ** * *** * * * * ** ** * * ***** * *** bills:0\n");
** ** * ** * * ** * * 0;

}
answered by (-258 points)
0 like 0 dislike
Hidden content!
**** * ***** * ***

int ** *** ****** *

int * *** *

{

scanf **** * ****** * *
* ** * *
****

b=b+1;

}
** * * ** * * ** * ***
**** * ******
** *

c=c+1;

}
* * * ** ** ** * ***** ** **
* ** * **
* *

d=d+1;

}
*** * * * * * * ****
** *** * *** *

a=a-50;

e=e+1;

}
**** ** ** * * * ***
* ** *****
*** *

f=f+1;

}
***** ** * ** * * *
** *****

a=a-5;

g=g+1;

}
*** *** * * * ** * ***** ****
* * * * * **

a=a-1;

h=h+1;

}
*** * * **** ** ***

}
answered by (-336 points)
0 like 0 dislike
Hidden content!
#include <stdio.h>



int main(void)

{

    int a;

    a=763;
* * *** * **** * * * *** ** ** *
**** ** * ** **** **** ** *** * * ***** **
* * * * *** ** * * ******* * * * * * * ** *
* * * **** *** ** ** ** ***** **
* * ** * * * **** ** * *** ** * ** * * **
** *** *** *** ** ** * ** * ** ** * ** *
***** *** ** *** *** *** * **** ** * *
** * * ** * ** * * * **** **
*** * * ******* * ** ** 0;

}
answered by (42 points)
0 like 0 dislike
Hidden content!
** ** ** ** ******

int ** *** * *





int * **

{

scanf * * ** ** * ** **


** * ** *
* *

b=b+1;

}
** * ** ********* * * * * *


** ****
* ** *

c=c+1;

}
* **** ** ** ** * ****


*** **** *
* *
**

}
** ** *** ** *** ***** *


*** * ** *
* *

e=e+1;

}
* ** * * **** ** * *


** * ** *****
*

f=f+1;

}
**** *** *** *** * * * *


***** * ** **

a=a-5;

g=g+1;

}
** ***** * ** *******


* * * ** **

a=a-1;

h=h+1;

}
** **** * * * * **

}
answered by (-336 points)
0 like 0 dislike
Hidden content!
#include <stdio.h>

#include <stdlib.h>



int main()

{
* ** * ** **** * * a;
* *** * *** *** **** * ***** *** **
** ******* ** ***** ** ** *** *
** * ***** *** * *** ***** ** * * ** ** * * ** ** * ** bills:%d\n",a/1000);
* **** *** * * * ** *
* ** * *** * * ***** ***** **** *** * ** * *** ** * bills:0\n");


* * * * ** *** * *******
* * **** *** * * ***** **** *** ** * * ***** * ***** ** ** * bills:%d\n",a%1000/500);
** * ** ** * * *** *** *****
* *** * ****** * * ** **** ** * ** * * * * ** bills:0\n");


** * ** ** * * *** ****** * * * **
*** * * **** * *** * *** **** * * ** * * *** ** *** bills:%d\n",(a%1000-500)/100);
** * * * * * ** *** if(a>99)
* ** ** ** * * * * * *** ** ** ** ** * * ***** bills:%d\n",a%1000/100);
** *** * *** * * ****
* *** *** * *** ** * * *** * *** * **** *** * * *** bills:0\n");


* * **** ** * ** **
** * * * * * * * * * * ** * * ** *** ** ** ** *** *** bills:%d\n",a%1000%100/50);
* ****** * * ** ** ***
*** * ***** *** * * *** * * * ** *** *** * ** * *** bills:0\n");


** **** * ** * ** * **** ** * **
** **** ****** *** *** ** **** *** **** * * ** * * * bills:%d\n",(a%1000%100-50)/10);
* * * **** ** *** * ****
*** * * * ** *** *** * * ** * *** * * ** ** * * ** bills:0\n");


* * * * * * * ** ******
*** ** * * ** * **** ********** ** *** * * * ** bills:%d\n",a%1000%100%10/5);
** * * * * **** ****
** * * * ** ** ** * * *** ** *** ** * ** ** * ** * * * bills:0\n");


* ** *** * * *** * ** ** **
***** * **** ** * * *** * * **** *** ***** ** **** bills:%d\n",a%1000%100%10%5/1);
* ***** *** * ****** ** * *
** ** * * ** * * * * ****** *** ** * ***** **** bills:0\n");
** * *** * * 0;

}
answered by (-258 points)
0 like 0 dislike
Hidden content!
*** * * * *** *

int main()

{
**** * * * a,b,c,d,e,f,g,x;
** **** * *** * **** ** *** &x);

  a = x/1000;
** * *** ** * = (x-a*1000)/500;

  c = (x-a*1000- b*500)/100;
* * *** * = ******** * * *
**** ** * = * * * *** * *
* **** ** = * * ** ** *** * *

  g = * * ** *** * ** ** *
* **** ** ** * ** ** ** ** * ** * * ** *
*** * * ** **** * * * * * * * ** * *
** * * ** ** *** * *** *** **** ** *
* **** * * *** *** **** * * * * *
* *** ** * ***** *** * * * * * ** *
** ***** *** ** ** * ** **
*** ******** * * * * * * * *
* * * * * * 0;

}
answered by (-281 points)
Welcome to Peer-Interaction Programming Learning System (PIPLS) LTLab, National DongHwa University
English 中文 Tiếng Việt
IP:104.23.243.109
©2016-2026

Related questions

1 like 0 dislike
0 answers
[Resource] asked Oct 14, 2017 in Chapter 4: Expressions by thopd (12.1k points)
ID: 26949 - Available when: Unlimited - Due to: Unlimited
| 15 views
12,783 questions
183,442 answers
172,219 comments
4,824 users