From 119fec62241b3397863e23c7822453b928e5773e Mon Sep 17 00:00:00 2001 From: Vichingo455 Date: Wed, 16 Oct 2024 08:53:06 +0000 Subject: [PATCH] Upload files to "/" --- elaborato3.cpp | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 elaborato3.cpp diff --git a/elaborato3.cpp b/elaborato3.cpp new file mode 100644 index 0000000..30373b0 --- /dev/null +++ b/elaborato3.cpp @@ -0,0 +1,33 @@ +/* +AUTORE: Manuel Vichi +Elaborato 3 +*/ +#include +using namespace std; +int main(void) { + unsigned int numero,invertito = 0,resto,complemento,cifre = 1,temp = 0,potenza = 1; + cout << "Inserisci un numero intero positivo: "; + cin >> numero; + cout << endl; + temp = numero; + //Inversione Cifre + while (temp > 0){ + resto = numero % 10; + invertito = invertito * 10 + resto; + temp = (numero - resto) / 10; + } + temp = numero; + //Complemento a 10 + do { + temp = temp / 10; + cifre++; + } while (temp != 0); + while (cifre > 0) { + potenza = potenza * 10; + cifre--; + } + complemento = potenza - numero; + cout << "Il numero " << numero << "invertito e': " << invertito << endl; + cout << "Il complemento a 10 di " << numero << " e': " << complemento << endl; + return 0; +}