ww4445 @ 2021-01-10 21:44:28
#include<iostream>
#include<cmath>
#include<cstdio>
using namespace std;
int main(){
double a1,a2,b1,b2,c1,c2;
//scanf("%lflf%lf%lf%lf%lf",&a1,&a2,&b1,&b2,&c1,&c2);
cin>>a1>>a2>>b1>>b2>>c1>>c2;
double s=sqrt((a1-b1)*(a1-b1)+(a2-b2)*(a2-b2))+sqrt((b1-c1)*(b1-c1)+(b2-c2)*(b2-c2))+sqrt((a1-c1)*(a1-c1)+(a2-c2)*(a2-c2));
printf("%.2lf\n",s);
return 0;
}
如上,cin无问题,scanf莫名结果都为0,是吧空格读上了吗?
by FunnyCreatress @ 2021-01-10 21:48:02
%lflf
iee
by CGDGAD @ 2021-01-10 21:48:35
@ww4445 ?
%lflf是什么
by EuphoricStar @ 2021-01-10 21:48:59
@ww4445 少了个 %
正确代码:
#include<iostream>
#include<cmath>
#include<cstdio>
using namespace std;
int main(){
double a1,a2,b1,b2,c1,c2;
scanf("%lf%lf%lf%lf%lf%lf",&a1,&a2,&b1,&b2,&c1,&c2);
double s=sqrt((a1-b1)*(a1-b1)+(a2-b2)*(a2-b2))+sqrt((b1-c1)*(b1-c1)+(b2-c2)*(b2-c2))+sqrt((a1-c1)*(a1-c1)+(a2-c2)*(a2-c2));
printf("%.2lf\n",s);
return 0;
}
by ww4445 @ 2021-01-13 14:10:25
@NSObject (。_。)
by MarvinWang @ 2021-05-29 08:47:20
@NSObject lf=long float=double类型
by CGDGAD @ 2021-05-29 09:58:40
@wasitaratisaw 那个是两个 lf
(草,四个半月以前的帖子怎么被拿出来考古了)
by MarvinWang @ 2021-05-29 22:32:04
。。。