TOPIC

Como fiz - C++

DeyvsonLuiz asked 1 year ago

include

using namespace std;

int main() {

int notas[]={100, 50, 20, 10, 5, 2};
int preco, pagamento, resposta=0;
cin >> preco >> pagamento;

while(preco!=0 && pagamento!=0){
    int troco=pagamento-preco;
    for(int i=0; i<6; i++){
        if(notas[i]<=troco){
            troco-=notas[i];
            resposta++;
        }
    }

    if(resposta==2){ cout << "possible" << endl; }
    else{ cout << "impossible" << endl; }

    resposta=0;
    cin >> preco >> pagamento;
}

return 0;

}

Remember not post solutions. Your post may be reviewed by our moderators.

  • feodorv replied 1 year ago

    What is your problem? Is it AC or WA code? Why many topics with the same title "Como fiz"?