Runtime Error
/in/foo.cc: In function 'int main()': /in/foo.cc:20:39: warning: format '%d' expects argument of type 'int*', but argument 2 has type 'long long int*' [-Wformat=] while(scanf("%d %d %d %d",&x,&y,&z,&p)==4) ~~ ^ /in/foo.cc:20:39: warning: format '%d' expects argument of type 'int*', but argument 3 has type 'long long int*' [-Wformat=] /in/foo.cc:20:39: warning: format '%d' expects argument of type 'int*', but argument 4 has type 'long long int*' [-Wformat=] /in/foo.cc:20:39: warning: format '%d' expects argument of type 'int*', but argument 5 has type 'long long int*' [-Wformat=]
代码
#include<iostream>
#include<cmath>
using namespace std;
long long x,y,z,p,ans;
void work(int &x,int &y)
{
for(int i=2;i<=sqrt(x)&&i<=sqrt(y);i++)
{
if(x%i==0&&y%i==0)
{
x/=i;
y/=i;
work(x,y);
break;
}
}
}
int main()
{
while(scanf("%d %d %d %d",&x,&y,&z,&p)==4)
{
if(x==z&&y==p)
cout<<"Error"<<endl;
else
{
int k2=p-y,k1=z-x;
if(abs(k2)%abs(k1)==0)
{
ans=k2/k1;
cout<<"y=";
if(ans==-1)
cout<<"-";
else if(ans!=1)
cout<<ans;
cout<<"x";
}
work(k1,k2);
if(abs(k2)%abs(k1)!=0) cout<<"y="<<k1<<"/"<<k2<<"x";
int t=y-(x*k1/k2);
if(t>0)
cout<<"+"<<t<<endl;
else cout<<"t"<<endl;
}
}
return 0;
}