School Commit Init
This commit is contained in:
@@ -0,0 +1,15 @@
|
||||
//Knowing that we have coins of 1, 2 and 5 units, determine the minimum number of coins to pay a given amount.
|
||||
|
||||
#include<stdio.h>
|
||||
int main(){
|
||||
int n,ones,twos,fives;
|
||||
printf("Enter a number: ");
|
||||
scanf("%d",&n);
|
||||
fives=n/5;
|
||||
n%=5;
|
||||
twos=n/2;
|
||||
n%=2;
|
||||
ones=n;
|
||||
printf("The minimum number of coins required are: %d of 5's, %d of 2's and %d of 1's.\n ",fives,twos,ones);
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user