#include #include <limits> void clear(std::istream& in) { in.clear(); in.ignore(std::numeric_limits<std::streamsize>::max(), '\n'); } void son() { // Beep(523,50); // Beep(587,50); // Beep(659,50); // Beep(698,50); // Beep(784,500); } void son1() { for(int i = 0; i < 20; ++i) { // Beep(100*i,50); } } void afficher() { std::cout << "Choix de la table dans la liste suivante:" << std::endl; for (int i = 10; i > 0; --i) { std::cout << i; if (i != 1) std::cout << " | " ; } std::cout << std::endl; } int jeu(int c) { int res; int faute = 0; for (int i = 1; i <= 10; ++i) { do { std::cout << c << " x " << i << " = "; // Beep(1000,50); std::cin >> res; clear(std::cin); if (res != c * i) { std::cout << "Mauvaise reponse\n"; son(); ++faute; } } while (res != c * i); } return faute; } int askTable() { int table = 0; while (table < 1 || table > 10) { std::cout << "Entrez la table:"; std::cin >> table; clear(std::cin); if (table < 1 || table > 10) std::cout << "La table doit être comprise entre 1 et 10" << std::endl; } return table; } void jouer() { std::cout << "Entre les reponse puis valide par entree" << std::endl << "Es-tu pret pour commencer ?\n"; son(); int table = askTable(); int faute = jeu(table); std::cout << std::endl << "note : " << 10 - faute << "/10" << std::endl; son1(); } bool menuJouer() { char c; std::cout << "Jeu de calcul\nVoulez vous commencer le jeu (O ou N) "; std::cin >> c; clear(std::cin); while (true) { switch (c) { case 'N': case 'n': std::cout << "Vous avez choisi de ne pas jouer\nAu revoir et a bientot!!\n"; son1(); return false; case 'O': case 'o': std::cout << "Vous avez choisi de jouer tres bien !! \n"; return true; default: std::cout << "Tapez O ou N : "; std::cin >> c; clear(std::cin); break; } } } int main() { // Je retirerais cela, très ennuyant pour un utilisateur. if (!menuJouer()) return 1; jouer(); // system ("pause"); return 0; }
void affiche(int i) { std::cout<<"int:"<<i<<std::endl; } int main() { affiche(12); }
int aucarre(int i) { return i * i; } int main() { std::cout<<"carre:"<<aucarre(4)<<std::endl; }
vous voulez dire que le return retourne ici dans l'exemple 16 par le biais de la variable i
int fonction() { return 42; } int main() { int i = fonction(); return 0; }
le int c est donc égale a false ??
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre questionint jeu(int c) { int res; int faute = 0; for (int i = 1; i <= 10; ++i) { do { std::cout << c << " x " << i << " = "; // Beep(1000,50); std::cin >> res; clear(std::cin); if (res != c * i) { std::cout << "Mauvaise reponse\n"; son(); ++faute; } } while (res != c * i); } return faute; }