## 啊啊啊啊,这是为什么啊啊啊!膜拜巨佬
查看原帖
## 啊啊啊啊,这是为什么啊啊啊!膜拜巨佬
406817
Daaaaaaazai楼主2022/2/16 21:43
#include <iostream>
#include <cstdio>
#include <cmath>
using namespace std;

int main()
{
	double a,b,c,p,m,n;
	scanf("%lf %lf %lf",&a,&b,&c);
	p=(a+b+c)/2;
	m=p*(p-a)*(p-b)*(p-c);
	n=sqrt(m);
	printf("%.1lf",n);
	return 0;	
}

为什么?!这个是对的,然而...当本傻逼将除以2变成*1/2(放在前面),这个玩意就错了(哭)错误程序如下:

#include <iostream>
#include <cstdio>
#include <cmath>
using namespace std;

int main()
{
	double a,b,c,p,m,n;
	scanf("%lf %lf %lf",&a,&b,&c);
# 	p=1/2*(a+b+c);
	m=p*(p-a)*(p-b)*(p-c);
	n=sqrt(m);
	printf("%.1lf",n);
	return 0;	
}
拜托啦!!!
2022/2/16 21:43
加载中...