Upload files to "/"
This commit is contained in:
parent
72bd09679e
commit
119fec6224
|
@ -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;
|
||||||
|
}
|
Loading…
Reference in New Issue