Guest User

Untitled

a guest
Jul 23rd, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.69 KB | None | 0 0
  1. #include <iostream>
  2. #include <cstdlib>
  3. using namespace std;
  4. int main()
  5. {
  6. int c;
  7. double a,b,i;
  8.  
  9. cout<<"請輸入兩個數字以求最大公因數以及最小公倍數:"<<endl;
  10. cin>>a;
  11. cin>>b;
  12. while(i!=1)
  13. {
  14. if((a/i)-(int)(a/i)!=0&&(b/i)-(int)(b/i)!=0)
  15. {
  16. i++;
  17. }
  18. else
  19. {
  20. break;
  21. }
  22.  
  23. }
  24.  
  25. cout<<"最大公因數為:"<<i<<endl;
  26.  
  27. while(i=1)
  28. {
  29. if((a/i)-(int)(a/i)!=0&&(b/i)-(int)(b/i)!=0)
  30. {
  31. i++;
  32. }
  33. else
  34. {
  35. break;
  36. }
  37.  
  38. }
  39. cout<<"最大公因數為:"<<i<<endl;
  40. system("pause");
  41. return 0;
  42. }
Add Comment
Please, Sign In to add comment