RE求助
查看原帖
RE求助
964822
protractor半圆仪楼主2023/7/4 22:23
#include<iostream>
#include<cmath>
using namespace std;
int m(int a,int b)
{
	if(a<b)
	{
		a=a+b;
		b=a-b;
		a=a-b;
	}
	while(1)
	{
		int c=a%b;
		if(!c) return abs(b);
		else a=b,b=c;
	}
}
int main()
{
	int a,b,x,y;
	cin>>a>>b>>x>>y;
	int c1=y-b,c2=x-a;
	cout<<"y=";
	bool b_=(abs(c1)==c1)^(abs(c2)==c2);
	if(b_) cout<<'-';
	c1=abs(c1),c2=abs(c2);
	int c=m(c1,c2);
	cout<<c1/c;
	if(c2/c!=1) cout<<'/'<<c2;
	cout<<'x';
	int d1=a*c1/c*(0-int(b_)),d2=c2/c;
	int c_=m(abs(d1),d2);
	d1/=c_,d2/=c_;
	int ans=b*d2-d1;
	if(ans>0) cout<<'+';
	cout<<ans;
	if(d2!=1) cout<<'/'<<d2;
	return 0;
}

re了,但是在电脑自测没问题,re信息:Runtime Error. Received signal 8: Floating-point exception.

哪位大佬看看

2023/7/4 22:23
加载中...