Procedure TForm1.Button4Click(Sender: TObject); var Buff: TNodePointer; x: TItem; i,j: Cardinal; begin i:=0; Buff:=Head; if(Buff^.Next=nil) then begin ShowMessage('В стеке один элемент!'); exit; end; while Buff <> nil do begin while (Buff^.Next<>nil) and (Buff^.Data=Buff^.Next^.Data) and not(isEmpty(Buff)) do begin pop(Buff^.Next,x); for j:=i to StringGrid1.RowCount-2 do StringGrid1.Cells[0,j]:=StringGrid1.Cells[0,j+1]; StringGrid1.RowCount:=StringGrid1.RowCount-1; end; Buff:=Buff^.Next; i:=i+1; end; end;
PS. Delphi у меня сейчас нет, так что проверяйте сами. Если что не так - сообщайте.
#include <iomanip
#include <cmath>
using namespace std;
double St(double x1, double y1, double x2, double y2)
{
return sqrt((y2-y1)*(y2-y1)+(x2-x1)*(x2-x1));
}
double Per(double a, double b, double c)
{
return a+b+c;
}
double S(double a, double b, double c)
{
double p2 = Per(a,b,c)/2;
return sqrt(p2*(p2-a)*(p2-b)*(p2-c));
}
int main()
{
double x1, y1, x2, y2, x3, y3;
double a, b, c, p, s;
cin >> x1 >> y1;
cin >> x2 >> y2;
cin >> x3 >> y3;
a = St(x1,y1,x2,y2);
b = St(x1,y1,x3,y3);
c = St(x2,y2,x3,y3);
p = Per(a,b,c);
s = S(a,b,c);
cout.setf(std::ios::fixed);
cout.precision(6);
cout << "p = " << p << "\n";
cout << "s = " << s << "\n";
system("Pause");
return 0;
}
Пример:
1 1
4 1
1 5
p = 12.000000
s = 6.000000