Find minimum number of coins that make a given value: Difference between revisions

no edit summary
mNo edit summary
imported>AldoBaldo
No edit summary
Line 345:
Igual que la entrada de FreeBASIC.
</pre>
 
 
=={{header|C}}==
<syntaxhighlight lang="c">
#include <stdio.h>
 
#define TOTAL 988
#define Q_VALUES 8
 
int main() {
const int kValues[Q_VALUES] = { 200, 100, 50, 20, 10, 5, 2, 1 };
int t, q, iv;
 
for( t=TOTAL, iv=0; iv<Q_VALUES; t%=kValues[iv], ++iv ) {
q = t/kValues[iv];
printf( "%4d coin%c of %4d\n", q, q!=1?'s':' ', kValues[iv] );
}
 
return 0;
}
</syntaxhighlight>
{{out}}
<pre>
4 coins of 200
1 coin of 100
1 coin of 50
1 coin of 20
1 coin of 10
1 coin of 5
1 coin of 2
1 coin of 1
</pre>
 
 
=={{header|Delphi}}==
Anonymous user