为啥我每次用结构体都出错?
查看原帖
为啥我每次用结构体都出错?
1078964
equipy_rrt楼主2023/11/26 14:43
#include<iostream>
#include<cmath>
using namespace std;

struct place{
	float x,y;
} pot[5];

float squ(float x){
	return pow(x,2);
}

float dis(float a,float b,float c,float d){
	return sqrt(squ(a-b)+squ(c-d));
}

int main(){
	float ans=0;
	for(int i=1;i<=3;i++) cin>>pot[i].x>>pot[i].y;
	ans+=dis(pot[2].x,pot[1].x,pot[2].y,pot[1].y);
	ans+=dis(pot[3].x,pot[2].x,pot[3].y,pot[2].y);
	ans+=dis(pot[3].x,pot[1].x,pot[3].y,pot[1].y);
	cout<<ans;
	return 0;
}
2023/11/26 14:43
加载中...