Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- int main()
- {
- int a,a_temp,b,b_temp,r=1,pgcd;
- char i='o';
- while(i=='o')
- {
- system("cls");
- printf("Calcule de PGCD de 'a' et 'b'\n\nVeuillez entrer la valeur de 'a' : ");
- scanf("%d",&a);
- //rewind(stdin);
- printf("\nVeuillez entrer la valeur de 'b' : ");
- scanf("%d",&b);
- //rewind(stdin);
- a_temp=a;
- b_temp=b;
- if(b>a)
- {
- a_temp=b;
- b_temp=a;
- a=a_temp;
- b=b_temp;
- }
- while((a_temp%b_temp)!=0)
- {
- r=a_temp%b_temp;
- a_temp=b_temp;
- b_temp=r;
- }
- pgcd=b_temp;
- printf("\nle PGCD (%d;%d) = %d\n",a,b,pgcd);
- rewind(stdin);
- printf("\n\ncontinuer? [o=oui/n=non] : ");
- rewind(stdin);
- scanf("%c",&i);
- printf("\n");
- rewind(stdin);
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement