+ 1
CENTROID
PROBLEM u r given a coordinates of a triangle's corners, (X1Y1),(X2Y2), and (X3Y3). Find the coordinates of the centroid of thr triangle (XC,YC),given that XC=(X1+X2+X3)/3 and YC=(Y1+Y2+Y3)/3. INPUT FORMAT: X1 Y1 X2 Y2 X3 Y3 OUTPUT FORMAT: XC YC SAMPLE INPUT: 0 0 1 1 2 5 SAMPLE OUTPUT: 1 2
2 Antworten
+ 2
#include <iostream>
using namespace std;
int main(){
double x1, x2, x3, y1, y2, y3, CX, CY;
cin>>x1>>y1>>x2>>y2>>x3>>y3;
CX = (x1 + x2 + x3)/3;
CY = (y1 + y2 + y3)/3;
cout<<"CX = "<<CX<<endl;
cout<<"CY = "<<CY<<endl;
return 0;
}
+ 1
thanks..