Advertisement
Guest User

Untitled

a guest
Mar 29th, 2015
212
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.99 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. int main()
  5. {
  6.  
  7. int a,a_temp,b,b_temp,r=1,pgcd;
  8. char i='o';
  9.  
  10. while(i=='o')
  11. {
  12. system("cls");
  13. printf("Calcule de PGCD de 'a' et 'b'\n\nVeuillez entrer la valeur de 'a' : ");
  14. scanf("%d",&a);
  15. //rewind(stdin);
  16. printf("\nVeuillez entrer la valeur de 'b' : ");
  17. scanf("%d",&b);
  18. //rewind(stdin);
  19. a_temp=a;
  20. b_temp=b;
  21.  
  22. if(b>a)
  23. {
  24. a_temp=b;
  25. b_temp=a;
  26. a=a_temp;
  27. b=b_temp;
  28. }
  29.  
  30. while((a_temp%b_temp)!=0)
  31. {
  32. r=a_temp%b_temp;
  33. a_temp=b_temp;
  34. b_temp=r;
  35. }
  36.  
  37. pgcd=b_temp;
  38. printf("\nle PGCD (%d;%d) = %d\n",a,b,pgcd);
  39. rewind(stdin);
  40.  
  41. printf("\n\ncontinuer? [o=oui/n=non] : ");
  42. rewind(stdin);
  43. scanf("%c",&i);
  44. printf("\n");
  45. rewind(stdin);
  46. }
  47. return 0;
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement