fork download
  1. #include <iostream>
  2. #include <cmath>
  3.  
  4. using namespace std;
  5.  
  6. int main()
  7. {
  8.  
  9. int iN, b100 = 100, b50 = 50, b20 = 20, b10 = 10, b5 = 5, b2 =2, b1 = 1;
  10. long double N, fN, bp50 = 0.50, bp25 = 0.25, bp10 = 0.10, bp05 = 0.05, bp01 =0.01;
  11.  
  12. int i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0;
  13.  
  14. cin >> N;
  15.  
  16.  
  17. iN = N;
  18. fN = (N-iN)+0.000005;
  19.  
  20.  
  21. i = iN / b100;
  22. iN %= b100;
  23.  
  24. j = iN / b50;
  25. iN %= b50;
  26.  
  27. k = iN / b20;
  28. iN %= b20;
  29.  
  30. l = iN / b10;
  31. iN %= b10;
  32.  
  33. m = iN / b5;
  34. iN %= b5;
  35.  
  36. n = iN / b2;
  37. iN %= b2;
  38.  
  39. o = iN / b1;
  40. iN %= b1;
  41.  
  42.  
  43. p = fN / bp50;
  44. fN = fmod(fN,bp50);
  45.  
  46. q = fN / bp25;
  47. fN = fmod(fN,bp25);
  48.  
  49. r = fN / bp10;
  50. fN = fmod(fN,bp10);
  51.  
  52. s = fN / bp05;
  53. fN = fmod(fN,bp05);
  54.  
  55.  
  56. t = fN / bp01;
  57.  
  58. cout << "NOTAS:" << endl;
  59. cout << i << " nota(s) de R$ 100.00" << endl;
  60. cout << j << " nota(s) de R$ 50.00" << endl;
  61. cout << k << " nota(s) de R$ 20.00" << endl;
  62. cout << l << " nota(s) de R$ 10.00" << endl;
  63. cout << m << " nota(s) de R$ 5.00" << endl;
  64. cout << n << " nota(s) de R$ 2.00" << endl;
  65. cout << "MOEDAS:" << endl;
  66. cout << o << " moeda(s) de R$ 1.00" << endl;
  67. cout << p << " moeda(s) de R$ 0.50" << endl;
  68. cout << q << " moeda(s) de R$ 0.25" << endl;
  69. cout << r << " moeda(s) de R$ 0.10" << endl;
  70. cout << s << " moeda(s) de R$ 0.05" << endl;
  71. cout << t << " moeda(s) de R$ 0.01" << endl;
  72. return 0;
  73. }
  74.  
Success #stdin #stdout 0s 15240KB
stdin
Standard input is empty
stdout
NOTAS:
-21474836 nota(s) de R$ 100.00
0 nota(s) de R$ 50.00
-2 nota(s) de R$ 20.00
0 nota(s) de R$ 10.00
-1 nota(s) de R$ 5.00
-1 nota(s) de R$ 2.00
MOEDAS:
-1 moeda(s) de R$ 1.00
-2147483648 moeda(s) de R$ 0.50
-2147483648 moeda(s) de R$ 0.25
-2147483648 moeda(s) de R$ 0.10
-2147483648 moeda(s) de R$ 0.05
-2147483648 moeda(s) de R$ 0.01