1 solutions

  • 0
    @ 2025-11-5 19:23:13

    C :

    #include <stdio.h>
    int main()
     {
      int  p,r,n,m,temp;
      scanf("%d%d,",&n,&m);
      if (n<m)
       {
        temp=n;
        n=m;
        m=temp;
       }
      p=n*m;
      while(m!=0)
       {
        r=n%m;
        n=m;
        m=r;
       }
      printf("%d %d\n",n,p/n);
      return 0;
     }
    

    C++ :

    #include<iostream>
    using namespace std;
    int main()
    {
        int a,b,c,d,min;
        cin>>a>>b;
        if(a>b)
            c=a,a=b,b=c;
        if(b%a==0)
        {
            d=a;
            cout<<a<<' ';
        }
        else
            for(c=a-1; c>=1; c--)
                if(a%c==0&&b%c==0)
                {
                    cout<<c<<' ';
                    d=c;
                    break;
                }
                cout<<a*b/d<<endl;
    }
    
    
    • 1

    C语言程序设计教程(第三版)课后习题6.1

    Information

    ID
    19321
    Time
    1000ms
    Memory
    128MiB
    Difficulty
    (None)
    Tags
    # Submissions
    0
    Accepted
    0
    Uploaded By