Advertisement
obstinado-yamada

Untitled

Sep 6th, 2016
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.66 KB | None | 0 0
  1. #include<iostream>
  2. #include<cmath>
  3. using namespace std;
  4. int main(){
  5. int a,b,x,i,y;
  6. cout<<" programme que clacul lcm "<<endl;
  7. cout<<"entrer le premier nombre a"<<endl;
  8. cin>>a;
  9. cout<<"entrer le deuxiem nombre b "<<endl;
  10. cin>>b;
  11. i=1;
  12. int z=1;
  13. x=a;
  14. y=b;
  15. do {
  16. if(a>=b){
  17. x=a*z;
  18. z++;
  19. i=1;
  20. while((x!=y)&&(i<100)){
  21. y=b*i;
  22. i++;
  23. }
  24. }
  25. else if (a<b ){
  26. y=b*z;
  27. z++;
  28. i=1;
  29.  
  30. while((x!=y)&&(i<100)){
  31.  
  32. x=a*i;
  33. i++;
  34.  
  35. }
  36.  
  37. }
  38.  
  39.  
  40.  
  41. }while(x!=y);
  42.  
  43.  
  44.  
  45. cout << "lcm a, b = " << x << endl;
  46.  
  47. getchar();
  48. return 0;
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement