Hey so i was doing this excercise and i figured out that when you use fout instead of cout it prints a different number when you have to print the thing i higlihted in the code example if you put in
14 -783 421 693
-153 680 443 741
as an imput
it will cout 595441
and it will fout 0595441
#include <bits/stdc++.h>
using namespace std;
int main() {
ifstream fin("billboard.in");
ofstream fout("billboard.out");
int x1,y1,x2,y2,px1,py1,px2,py2;
fin>>x1>>y1>>x2>>y2>>px1>>py1>>px2>>py2;
x1+=1000;
x2+=1000;
y1+=1000;
y2+=1000;
px1+=1000;
px2+=1000;
py1+=1000;
py2+=1000;
int a1=(x2-x1)*(y2-y1);
if(x2<=px2&&x1>=px1&&y2<=py2&&y1>=py1){
fout<<0;
}
else if(x2<=px2&&x1>=px1){
if(py2>=y2){
fout<<0;
}
if((py2<=y1)|(py1>y1&&py2<y2) ){
fout<<a1;
}else{
int ma=max(py1,y1);
int mi=min(py2,y2);
fout<<((x2-x1)*(y2-y1))-((x2-x1)*(mi-ma));
cout<<((x2-x1)*(y2-y1))-((x2-x1)*(mi-ma)); /********************************************************/
}
}
else if(y2<=py2&&y1>=py1){
if(px2<=x1|px1>x1){
fout<<a1;
}else{
int ma=max(px1,x1);
fout<<((y2-y1)*(x2-x1))-((y2-y1)*(px2-ma));
}
}
else{
fout<<a1;
}
return 0;
}
Aucun commentaire:
Enregistrer un commentaire