# 点线面

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
//

//

class Program
{
static void Main(string[] args)
{
CPoint p1 = new CPoint();
CPoint p4 = new CPoint();
int i;
// Console.WriteLine(num);
p1.setPoint(num,num);
p4.setPoint(num2,num2);
CRect cr=new CRect();

Cline cl1 = new Cline();

Console.WriteLine("p1p2={0}",cl1.Dis(p1,p4));
Console.WriteLine("Perimeter and area={0},{1}", cr.Getlength(p1, p4), cr.Getarea(p1, p4));

}
}
}

``````1
2
``````

``````p1p2=1.4142135623731
Perimeter and area=4,1``````

``````using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
class CPoint
{
public double x;
public double y;
public double GetX() { return x; }
public double GetY() { return y; }
public void setPoint(int m,int n){x=m;y=n;}

}
class Cline : CPoint
{
public double Dis(CPoint P1,CPoint P2)
{
double dis;
dis = Math.Sqrt((P1.GetX() - P2.GetX()) * (P1.GetX() - P2.GetX()) + (P1.GetY() - P2.GetY()) * (P1.GetY() - P2.GetY()));
return dis;
}
}
class CRect : Cline
{
public  CRect() { }
double length=0, area=0;
public double Getlength(CPoint p1,CPoint p4)
{
return length = 2 * (Math.Abs((p1.GetY() - p4.GetY())) + Math.Abs((p4.GetX() - p1.GetY())));
}
public double Getarea(CPoint p1,CPoint p4)
{
return area = Math.Abs(p1.GetY() - p4.GetY()) * Math.Abs(p4.GetX() - p1.GetY());
}
}
class Program
{
static void Main(string[] args)
{
Console.WriteLine("p1=(1,1),p4=(2,2)");
CPoint p1 = new CPoint();
CPoint p4 = new CPoint();
int i;
// Console.WriteLine(num);
p1.setPoint(1,1);
p4.setPoint(2,2);
CRect cr=new CRect();

Cline cl1 = new Cline();

Console.WriteLine("p1p2={0}",cl1.Dis(p1,p4));
Console.WriteLine("矩形的周长为{0},面积为{1}", cr.Getlength(p1, p4), cr.Getarea(p1, p4));

}
}
}``````

``````using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
class CPoint
{
public double x;
public double y;
public double GetX() { return x; }
public double GetY() { return y; }
public void setPoint(int m,int n){x=m;y=n;}

}
class Cline : CPoint
{
public double Dis(CPoint P1,CPoint P2)
{
double dis;
dis = Math.Sqrt((P1.GetX() - P2.GetX()) * (P1.GetX() - P2.GetX()) + (P1.GetY() - P2.GetY()) * (P1.GetY() - P2.GetY()));
return dis;
}
}
class CRect : Cline
{
public  CRect() { }
double length=0, area=0;
public double Getlength(CPoint p1,CPoint p4)
{
return length = 2 * (Math.Abs((p1.GetY() - p4.GetY())) + Math.Abs((p4.GetX() - p1.GetY())));
}
public double Getarea(CPoint p1,CPoint p4)
{
return area = Math.Abs(p1.GetY() - p4.GetY()) * Math.Abs(p4.GetX() - p1.GetY());
}
}
class Program
{
static void Main(string[] args)
{
Console.WriteLine("p1=(1,1),p4=(2,2)");
CPoint p1 = new CPoint();
CPoint p4 = new CPoint();
int i;
// Console.WriteLine(num);
p1.setPoint(1,1);
p4.setPoint(2,2);
CRect cr=new CRect();

Cline cl1 = new Cline();

Console.WriteLine("p1p2={0}",cl1.Dis(p1,p4));
Console.WriteLine("矩形的周长为{0},面积为{1}", cr.Getlength(p1, p4), cr.Getarea(p1, p4));