Baixe o app para aproveitar ainda mais
Prévia do material em texto
#include <cstdlib> #include <iostream> using namespace std; int valor, i; void ler_valor () // não retorna valor (void) { cout<<"informe o numero a ser descoberto "; cin>> valor; system("cls"); // ocultar o valor na tela } int palpite() { int palpit; cout<<"de o seu palpite "; cin>> palpit; if (palpit == valor) { cout<< "Excelente! Você adivinhou o numero!"; i = 11; } else if (palpit > valor) { cout<<"Muito alto. Tente novamente."; i++; } else { cout<<"Muito baixo. Tente novamente."; i++; } return i; } int main(int argc, char *argv[]) { i = 0; ler_valor (); while (valor>=0) { while ( palpite () != 11); ler_valor (); } if (i == 10) cout<<"você perdeu!"<<endl; system("PAUSE"); return EXIT_SUCCESS; }
Compartilhar