Open wuwusiqi opened 5 months ago
告诉我具体哪个测试集,我发给你测试集。 我们没法帮你把代码中的bug精确找出来,只能告诉你基本debug的方法。
Cheers, Xie Chen
From: wuwusiqi @.> Date: Sunday, March 3, 2024 at 9:24 PM To: chenxie95/SJTU_C-_Cource @.> Cc: Subscribed @.***> Subject: [chenxie95/SJTU_C-_Cource] 求助!分支结构第八题有一个测试值过不了,谢谢老师! (Issue #29)
using namespace std; int main() { double x,y,h; cin>>x>>y;
if ((x-2)(x-2)+(y-2)(y-2)>1&&(x+2)(x+2)+(y-2)(y-2)>1&&(x-2)(x-2)+(y+2)(y+2)>1&&(x+2)(x+2)+(y+2)(y+2)>1){
h=0;
}
else {
if(x<0){x=-x;}
else x=x;
if(y<0){y=-y;}
else y=y;
h=(10*(1-sqrt((x-2)(x-2)+(y-2)(y-2))));
}
cout<<h<<endl;
return 0;
} 2024-03-01.233244.png (view on web)https://github.com/chenxie95/SJTU_C-_Cource/assets/162029410/d929dfe7-827e-40b8-bbaf-5153f472bbbc
― Reply to this email directly, view it on GitHubhttps://github.com/chenxie95/SJTU_C-_Cource/issues/29, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AB4YE5NQB5NSOMTMR2CET33YWMP75AVCNFSM6AAAAABED62LM2VHI2DSMVQWIX3LMV43ASLTON2WKOZSGE3DKMZVG43DMNY. You are receiving this because you are subscribed to this thread.Message ID: @.***>
另外这个代码有一些直接可以看到有问题的地方,如(x-2)(x-2) 应该是 (x-2)*(x-2)
是测试集2不对 本身代码的确是(x-2)*(x-2)可能复制的时候出错了 谢谢老师!
include
include
using namespace std; int main() { double x,y,h; cin>>x>>y;
if ((x-2)(x-2)+(y-2)(y-2)>1&&(x+2)(x+2)+(y-2)(y-2)>1&&(x-2)(x-2)+(y+2)(y+2)>1&&(x+2)(x+2)+(y+2)(y+2)>1){ h=0; } else { if(x<0){x=-x;} else x=x; if(y<0){y=-y;} else y=y; h=(10(1-sqrt((x-2)(x-2)+(y-2)*(y-2)))); } cout<<h<<endl; return 0; }