LOVEGUN

Exercice 15 Série ISI

Oct 7th, 2021 (edited)
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.55 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. int main()
  5. {
  6.     int a,b,ab,ba,s;
  7.     do {
  8.         printf ("Donner un nombre strictement positif:\n");
  9.         scanf ("%d",&ab);
  10.     }while (ab<=9  || verif (ab)==0);
  11.     s=ab;
  12.     do {
  13.         ab=s;
  14.         ba=invers(ab);
  15.         s=abs(ab-ba);
  16.         printf ("%d\n",s);
  17.     }while (s!=9);
  18. }
  19.  
  20.  
  21. int invers (int ab)
  22. {
  23.     int a,b,s;
  24.     a=(ab/10);
  25.     b=ab%10;
  26.     s=a+(b*10);
  27.     return s;
  28. }
  29.  
  30. int verif (int ab)
  31. {
  32.     int a,b,s;
  33.     a=(ab/10);
  34.     b=ab%10;
  35.     s=a!=b;
  36.     return s;
  37. }
  38.  
Add Comment
Please, Sign In to add comment