Skip to content

Instantly share code, notes, and snippets.

@gabrielcesar
Created July 21, 2016 14:41
Show Gist options
  • Save gabrielcesar/d7b40d9924dd9300f6645bbd4da228fb to your computer and use it in GitHub Desktop.
Save gabrielcesar/d7b40d9924dd9300f6645bbd4da228fb to your computer and use it in GitHub Desktop.
t) Bancknotes and coins
/*
* t
*/
#include <stdio.h>
int main()
{
double n, d[] = { 100.0, 50.0, 20.0, 10.0, 5.0, 2.0, 1.0, 0.5, 0.25, 0.10, 0.05, 0.01 };
int t = 0, c;
scanf ( "%lf", &n );
printf ("NOTAS:\n" );
t = 0;
n += 1e-9;
while ( d[t] >= 0.01 )
{
c = 0;
while ( n >= d[t] )
{
n -= d[t];
c++;
}
if ( d[ t ] == 1.0 )
printf ( "MOEDAS:\n" );
if ( d[t] >= 2.0 )
printf ( "%d nota(s) de R$ %.2f\n", c, d[t] );
else
printf ( "%d moeda(s) de R$ %.2f\n", c, d[t] );
t++;
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment