这个visual c++ 6.0程序编译时没有出错,但运行时程序中止,求解
#include<iostream>usingnamespacestd;intg(inta,intb){intr;r=a%b;if(r=0)returnb;elseret...
#include<iostream>
using namespace std;
int g(int a,int b){int r;r=a%b;if(r=0) return b;else return g(b,r);}
int main()
{long int a,b,p,q,s;
cout<<"To get GCD and LCM"<<endl<<"please enter a,b:";
cin>>a>>b;
for(;a<=0||b<=0;){cout<<"please enter a,b>0:";cin>>a>>b;}
if(b>a) s=a,a=b,b=s;p=g(a,b);
q=a*b/p;
cout<<"(a,b)="<<p<<endl;
cout<<"[a,b]="<<q<<endl;
return 0;} 展开
using namespace std;
int g(int a,int b){int r;r=a%b;if(r=0) return b;else return g(b,r);}
int main()
{long int a,b,p,q,s;
cout<<"To get GCD and LCM"<<endl<<"please enter a,b:";
cin>>a>>b;
for(;a<=0||b<=0;){cout<<"please enter a,b>0:";cin>>a>>b;}
if(b>a) s=a,a=b,b=s;p=g(a,b);
q=a*b/p;
cout<<"(a,b)="<<p<<endl;
cout<<"[a,b]="<<q<<endl;
return 0;} 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询