Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* Letti tre numeri interi da tastiera visualizzare il massimo dei tre valori inseriti
- * Se i numeri sono uguali visualizzare un messaggio che lo segnala.
- */
- import std;
- int leggiIntero(std::string messaggio)
- {
- int n{ 0 };
- std::print("{}", messaggio);
- std::cin >> n; //nessun controllo per brevitá
- return n;
- }
- auto main() -> int
- {
- int a{ 0 }, b{ 0 }, c{ 0 };
- a = leggiIntero("Inserisci il primo numero: ");
- b = leggiIntero("Inserisci il secondo numero: ");
- c = leggiIntero("Inserisci il terzo numero: ");
- if (a == b)
- {
- if (a == c)
- {
- std::cout << "i tre numeri sono uguali" << std::endl;
- }
- else
- {
- if (a > c)
- {
- std::cout << a << std::endl;
- }
- else
- {
- std::cout << c << std::endl;
- }
- }
- }
- else
- {
- if (a < b)
- {
- if (b < c)
- {
- std::cout << c << std::endl;
- }
- else
- {
- std::cout << b << std::endl;
- }
- }
- else
- {
- if (a > c)
- {
- std::cout << a << std::endl;
- }
- else
- {
- std::cout << c << std::endl;
- }
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment