Upload files to "/"

This commit is contained in:
Vichingo455 2024-10-16 08:53:06 +00:00
parent 72bd09679e
commit 119fec6224
1 changed files with 33 additions and 0 deletions

33
elaborato3.cpp Normal file
View File

@ -0,0 +1,33 @@
/*
AUTORE: Manuel Vichi
Elaborato 3
*/
#include <iostream>
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;
}