Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #define MAX_FATTORI 9999
- #define MAX_RISULTATO 99999999
- int lettura_dati(int x)
- {
- int numero4, numero8;
- if (x==0)
- {
- do
- {
- printf("\nInserire un numero di 4 cifre \n");
- scanf("%d", &numero4);
- if(numero4>MAX_FATTORI)
- {
- printf("\nErrore, inserire un numero con almeno 4 cifre\n");
- }
- } while(numero4>MAX_FATTORI);
- return numero4;
- }
- else if(x==1)
- {
- do
- {
- printf("\nInserisci il risultato di 8 cifre \n");
- scanf("%d", &numero8);
- if(numero8>MAX_RISULTATO)
- {
- printf("\nErrore, il risultato deve avere almeno 8 cifre\n");
- }
- }while (numero8>MAX_RISULTATO);
- return numero8;
- }
- return 0;
- }
- int scomposizione_numeri(int radice_numerica)
- {
- int modulo; //dichiarazione di una variabile
- int somma=0;
- int rn;
- while(radice_numerica!=0)
- {
- modulo = radice_numerica % 10;
- radice_numerica/=10;
- somma += modulo;
- printf("\nRadice numerica %d\n", radice_numerica);
- printf("\nSomma %d\n", somma);
- }
- rn = somma;
- if(rn>9)
- {
- printf("\nSeconda radice\n");
- return scomposizione_numeri(rn);
- }
- printf("\nModulo di Radice numerica%d\n", rn);
- return rn;
- }
- int main()
- {
- int numero1=lettura_dati(0);
- int numero2=lettura_dati(0);
- int risultato=lettura_dati(1);
- int valore1=scomposizione_numeri(numero1);
- int valore2=scomposizione_numeri(numero2);
- int rnfinale=scomposizione_numeri(risultato);
- int risultato1 = valore1 * valore2;
- if (risultato1 == rn)
- {
- printf("\nIl valore e` sicuro all`11 per cento\n");
- return 0;
- }
- else
- {
- printf("\nIl valore non e` corretto\n");
- return 1;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement