di17863468973 @ 2024-12-30 22:19:44
内存超限???why???
#include<bits/stdc++.h>
using namespace std;
double p(double x1,double y1,double x2,double y2){
sqrt((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1));
}
int main(){
double C=0,a[3],b[3];
for(int i=1;i<=3;i++){
cin>>a[i]>>b[i];
if(i==3){
C+=(p(a[1],a[2],b[1],b[2])+p(a[2],a[3],b[2],b[3])+p(a[1],a[3],b[1],b[3]));
}
}
printf("%lf.2",C);
return 0;
}
有没有牢大大佬帮忙看一下~~
QwQ
by _Vistion_ @ 2024-12-30 22:32:32
你的函数p没有返回值
by _Vistion_ @ 2024-12-30 22:34:33
改成return sqrt((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1));
试试
by _Vistion_ @ 2024-12-30 22:35:42
a,b数组建议开大点,不够
by di17863468973 @ 2024-12-31 21:49:24
@Vistion 现在好了 只不过全WA了
by _Vistion_ @ 2025-01-01 07:11:21
@di17863468973
调好了
#include<bits/stdc++.h>
using namespace std;
double p(double x1,double y1,double x2,double y2){
return sqrt(abs(x2-x1)*abs(x2-x1)+abs(y2-y1)*abs(y2-y1));
}
int main(){
double C=0,a[10],b[10];
for(int i=1;i<=3;i++)
cin>>a[i]>>b[i];
C+=(p(a[1],b[1],a[2],b[2])+p(a[2],b[2],a[3],b[3])+p(a[1],b[1],a[3],b[3]));
printf("%.2lf",C);
return 0;
}