Advertisement
AlsuSitdikova

задача 12

Dec 16th, 2018
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.31 KB | None | 0 0
  1. #include <iostream>
  2. #include <cmath>
  3. using namespace std;
  4. double nod(int a,int b){
  5. int max;int p;
  6. if(a>b){
  7. max=a;
  8. }
  9. else{ max=b;
  10. }
  11. for(int i=max;i>=1;--i){
  12. if(((a%i)==0)&&((b%i)==0)){
  13. p=i;break;
  14. }
  15. }
  16. return p;
  17. }
  18. int main(){
  19. int a,b; cin>>a>>b;
  20. double k=nod(a,b);
  21. cout<<k;
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement