thien

BÀI 17

Mar 2nd, 2015
260
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.59 KB | None | 0 0
  1. BÀI 17:Nhập 2 số tự nhiên m,n rồi kiểm tra xem chúng có nguyên tố cùng nhau không
  2.  
  3.  
  4.  
  5. #include <stdio.h>
  6. #include <conio.h>
  7. #include <iostream.h>
  8. int UCLN(unsigned int m, unsigned int n) {
  9. if(m==n)
  10. return m;
  11. else if(m>n)
  12. return UCLN(m-n,n);
  13. elsereturn UCLN(m,n-m);}
  14. void main() {
  15. clrscr();
  16. unsigned int m,n;
  17. cout<<"\n Nhap m = "; cin>>m;
  18. cout<<"\n Nhap n = "; cin>>n;
  19. if (UCLN(m,n) ==1)
  20. cout<<"\n "<<m<<" va "<<n<<" la hai so nguyen to cung nhau";if (UCLN(m,n) !=1)cout<<"\n "<<m<<" va "<<n<<" khong phai la hai so nguyen to cung nhau";
  21. getch();}
Advertisement
Add Comment
Please, Sign In to add comment