Advertisement
Guest User

Untitled

a guest
May 23rd, 2017
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.28 KB | None | 0 0
  1. #include "stdafx.h"
  2. #include <iostream>
  3.  
  4. using namespace std;
  5.  
  6. int main(){
  7.     setlocale(0, "Portuguese");
  8.     int notas100 = 0;
  9.     int notas50 = 0;
  10.     int notas20 = 0;
  11.     int notas10 = 0;
  12.     int notas5 = 0;
  13.     int notas2 = 0;
  14.     int notas1 = 0;
  15.     int resto = 0;
  16.     int valorTotal = 0;
  17.    
  18.  
  19.     cout << "Digite o valor total: ";
  20.     cin >> valorTotal;
  21.    
  22.     while(valorTotal >= 100){
  23.         valorTotal = valorTotal - 100;
  24.     notas100++;
  25.     }
  26.     while(valorTotal >= 50){
  27.         valorTotal = valorTotal - 50;
  28.     notas50++;
  29.     }
  30.     while(valorTotal >= 20){
  31.         valorTotal = valorTotal - 20;
  32.     notas20++;
  33.     }
  34.     while(valorTotal >= 10){
  35.         valorTotal = valorTotal - 10;
  36.     notas10++;
  37.     }
  38.     while(valorTotal >= 5){
  39.         valorTotal = valorTotal - 5;
  40.     notas5++;
  41.     }
  42.     while(valorTotal >= 2){
  43.         valorTotal = valorTotal - 2;
  44.     notas2++;
  45.     }
  46.     while(valorTotal >= 1){
  47.         valorTotal = valorTotal - 1;
  48.     notas1++;
  49.     }
  50.  
  51.    
  52.     cout << "Notas de 100 recebidas: " << notas100 << endl;
  53.     cout << "Notas de 50 recebidas: " << notas50 << endl;
  54.     cout << "Notas de 20 recebidas: " << notas20 << endl;
  55.     cout << "Notas de 10 recebidas: " << notas10 << endl;
  56.     cout << "Notas de 5 recebidas: " << notas5 << endl;
  57.     cout << "Notas de 2 recebidas: " << notas2 << endl;
  58.     cout << "Notas de 1 recebidas: " << notas1 << endl;
  59.    
  60.     system("pause");
  61.     return 0;
  62. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement