Advertisement
Guest User

Esercizio 5

a guest
Oct 22nd, 2019
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.02 KB | None | 0 0
  1. #include <stdio.h>
  2. int main(void){
  3. /*DICHIARO LE VARIABILI*/
  4. int x,y,d;
  5. printf("inserisci due interi\n");
  6. printf("inserisci un intero tra 0 e 9\n");
  7. if (scanf("%d%d",&x,&y)!=2){ /*VERIFICO CHE I DATI INSERITI SIANO CORRETTI*/
  8. printf("le due cifre che hai inserito non sono interi\n");
  9. return 1;
  10. }
  11. if (scanf("%d",&d)!=1 || d<0 || d>9){
  12. printf("la cifra che hai inserito o non e' un intero o non e' compresa tra 0 e 9\n");
  13. return 1;
  14. }
  15. /* CREO UN CICLO WHILE PER VERIFICARE LA CONDIZIONE UTILIZZANDO IL RESTO DELLA DIVISIONE PER 10,SIA PER X CHE PER Y*/
  16. while (x!=0){
  17. if(x%10==d){
  18. x=1;
  19. break;
  20. }
  21. else
  22. x=x/10;
  23. }
  24. while (y!=0){
  25. if(y%10==d){
  26. y=1;
  27. break;
  28. }
  29. else
  30. y=y/10;
  31. }
  32. /*STAMPO A SCHERMO IL RISULTATO*/
  33. if (x==1 && y==1)
  34. printf("la condizione e' verificata\n");
  35. else
  36. printf("la condizione non e' verificata\n");
  37. return 0;
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement