就是说根据3个字符串的信息画出状态图,字符串a,b,c 的长度是一样的:1、字符串a:表示状态图的串并联关系,“1”表示串联,“0”表示并联。如:11100111,就表示该图形前三个和后三个节点为串联,4,5为并联关系。2、字符串b:表示节点的颜色, "1 "表示黑色,“2”表示红色,“0”表示白色。如:12000000,第一个节点为黑色,第二个为红色,其他都为白色。3、字符串c:表示字符串的形状, "1 "为圆圈, "0 "为方框。如:11101111,就表示除了第四个节点为方框外,其他的都为圆圈。
以下为根据上面a,b,c字符串生成状态图的基本模样,颜色还没表示出来。
[]
0-0-0 0-0-0
0
以下为根据上面a,b,c字符串生成状态图的基本模样,颜色还没表示出来。
[]
0-0-0 0-0-0
0
解决方案 »
- 请问在DELPHI中这样的代码该如何写?
- 高手请进,这个统计用一条Select语句能不能完成?在线等!
- DBGridEh在三层结构中,统计的问题?
- 提示DsgnIntf未找到是什么原因,我找不到DsgnIntf这个文件
- 请教,关于Delphi对象引用的一点疑惑?
- access 表中的datetime型字段在delphi中如何使用?
- 各位朋友们好,能看一下我这个有关Dbrid变色方面的问题吗?
- 在foxpro中要想查ID在61000到65000之间的数据,用between怎么用?
- WebBrowser1 小问题
- 如何在程序中获取ORACLE数据库的日期。
- 急!!!怎么保存在TCheckListBox里?!
- 怎样保存浏览过的IE网页?
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, Buttons;type
TForm1 = class(TForm)
BitBtn1: TBitBtn;
procedure BitBtn1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;implementation{$R *.DFM}procedure TForm1.BitBtn1Click(Sender: TObject);
var
s1,s2,s3:string;
oldPen : TPen;
oldBrush : TBrush;
i,iX,iUp,iDown,x,y:integer;
bY:boolean;begin
{*****************************************
ix 控制X轴步进 bY 为了好看,true 往Y轴上方加,false 往Y轴下方加
iDown Y轴上方位移,iUp Y轴下方位移
*****************************************}
s1 := '1100110011'; //并,串关系
s2 := '1200000012'; //颜色
s3 := '1110111101'; //形状
oldPen := Canvas.Pen;
OldBrush := canvas.Brush;
canvas.Pen.Color := clBlue;
for i:=1 to length(s1) do
begin
case s2[i] of
'0':Canvas.Brush.Color := clWhite;
'1':Canvas.Brush.Color := clBlack;
'2':Canvas.Brush.Color := clred;
end;
if i = 1 then
begin
x := 100;
y := 200;
iX := 0;
bY := true;
iUp := 0;
iDown := 0;
case s3[i] of
'0':
begin
canvas.Rectangle(x-10,y-10,x+10,y+10);
end;
'1':canvas.Ellipse(x-10,y-10,x+10,y+10);
end;
end
else
begin
if s1[i] = '1' then
begin
inc(iX);
iUp := 0;
iDown := 0;
if bY then
begin
x := 100+iX*40;
y := 200-iUp*30;
end
else
begin
x := 100+iX*40;
y := 200+iDown*30;
end;
end;
if s1[i] = '0' then
begin
if s1[i-1] ='1' then
inc(iX);
if bY then
begin
inc(iUp);
x := 100+iX*40;
y := 200-iUp*30;
bY := not By;
end
else
begin
inc(iDown);
bY := not By;
x := 100+iX*40;
y := 200+iDown*30;
end;
end;
case s3[i] of
'0':canvas.Rectangle(x-10,y-10,x+10,y+10);
'1':canvas.Ellipse(x-10,y-10,x+10,y+10);
end;
end;
end;
canvas.Brush := oldBrush;
canvas.Pen := oldpen;
end;end.//可能有点问题就是你的串连关系有时不一定符合逻辑。这类串我没处理。
s1,s2,s3:string;
oldPen : TPen;
oldBrush : TBrush;
i,iX,iUp,iDown,x,y:integer;
bY:boolean;begin
{*****************************************
ix 控制X轴步进 bY 为了好看,true 往Y轴上方加,false 往Y轴下方加
iDown Y轴上方位移,iUp Y轴下方位移
*****************************************}
s1 := '1100110011'; //并,串关系
s2 := '1200000012'; //颜色
s3 := '1110111101'; //形状
oldPen := Canvas.Pen;
OldBrush := canvas.Brush;
canvas.Pen.Color := clBlue;
for i:=1 to length(s1) do
begin
//设置节点颜色
case s2[i] of
'0':Canvas.Brush.Color := clWhite;
'1':Canvas.Brush.Color := clBlack;
'2':Canvas.Brush.Color := clred;
end;
//设置节点位置
if i = 1 then
begin
x := 100;
y := 200;
iX := 0;
bY := true;
iUp := 0;
iDown := 0;
end
else
begin
if s1[i] = '1' then
begin
inc(iX);
iUp := 0;
iDown := 0;
x := 100+iX*40;
y := 200;
end;
if s1[i] = '0' then
begin
if s1[i-1] ='1' then
inc(iX);
x := 100+iX*40;
if bY then
begin
inc(iUp);
y := 200-iUp*30;
bY := not By;
end
else
begin
inc(iDown);
bY := not By;
y := 200+iDown*30;
end;
end;
end;
//画图
case s3[i] of
'0':canvas.Rectangle(x-10,y-10,x+10,y+10);
'1':canvas.Ellipse(x-10,y-10,x+10,y+10);
end;
end;
canvas.Brush := oldBrush;
canvas.Pen := oldpen;
end;
s1,s2,s3:string;
oldPen : TPen;
oldBrush : TBrush;
i,iX,iUp,iDown,x,y:integer;
bY:boolean;begin
{*****************************************
ix 控制X轴步进 bY 为了好看,true 往Y轴上方加,false 往Y轴下方加
iDown Y轴上方位移,iUp Y轴下方位移
*****************************************}
s1 := '110101100110000011'; //并,串关系
s2 := '120010000120101201'; //颜色
s3 := '111011111011011111'; //形状
oldPen := Canvas.Pen;
OldBrush := canvas.Brush;
canvas.Pen.Color := clBlue;
for i:=1 to length(s1) do
begin
//设置节点颜色
case s2[i] of
'0':Canvas.Brush.Color := clWhite;
'1':Canvas.Brush.Color := clBlack;
'2':Canvas.Brush.Color := clred;
else
Canvas.Brush.Color := clWhite;
end;
//设置节点位置
if i = 1 then
begin
x := 100;
y := 200;
iX := 0;
bY := true;
iUp := 0;
iDown := 0;
end
else
begin
if s1[i] = '1' then
begin
inc(iX);
iUp := 0;
iDown := 0;
x := 100+iX*40;
y := 200;
end
else
begin
if s1[i-1] ='1' then
inc(iX);
x := 100+iX*40;
if bY then
begin
inc(iUp);
y := 200-iUp*30;
bY := not By;
end
else
begin
inc(iDown);
bY := not By;
y := 200+iDown*30;
end;
end;
end;
//画图
case s3[i] of
'0':canvas.Rectangle(x-10,y-10,x+10,y+10);
'1':canvas.Ellipse(x-10,y-10,x+10,y+10);
else
canvas.Rectangle(x-10,y-10,x+10,y+10);
end;
end;
canvas.Brush := oldBrush;
canvas.Pen := oldpen;
end;
var
s1,s2,s3:string;
oldPen : TPen;
oldBrush : TBrush;
i,iX,iUp,iDown,x,y:integer;
bY:boolean;
iXPosCount : array[1..100] of integer;
iPos,iP,j,k : integer;
begin
{*****************************************
ix 控制X轴步进 bY 为了好看,true 往Y轴上方加,false 往Y轴下方加
iDown Y轴上方位移,iUp Y轴下方位移,iXPosCount X轴某个位置上的节点个数.
iPos 指向当前iXPsCount位置.
*****************************************}
s1 := '11001011000110000011'; //并,串关系
s2 := '12010100000120101201'; //颜色
s3 := '11100111110011011111'; //形状
oldPen := Canvas.Pen;
OldBrush := canvas.Brush;
canvas.Pen.Color := clBlue;
iPos:=1;
for i:=1 to length(s1) do
begin
//设置节点位置
if i = 1 then
begin
iXPosCount[iPos]:=1;
end
else
begin
if s1[i] = '1' then
begin
Inc(iPos);
iXPosCount[iPos]:=1;
end
else
begin
if s1[i-1] ='1' then
begin
inc(iPos);
iXPosCount[iPos]:=1;
end
else
begin
inc(iXPosCount[iPos]);
end;
end;
end;
end;
//画图.
i:=1;
for ip:=1 to iPos do
begin
x := 100+iP*40;
if (iXPosCount[iP] mod 2)=0 then
begin
iUp :=0;
iDown := 0;
end
else
begin
iUp :=-1;
iDown := 0;
end;
bY := true;//相向上画.
for j := 1 to iXPosCount[iP] do
begin
if bY then
begin
inc(iUp);
y := 200-iup*40;
by := not by;
end
else
begin
inc(iDown);
y := 200+iDown*40;
by := not by;
end;
//设置节点颜色
case s2[i] of
'0':Canvas.Brush.Color := clWhite;
'1':Canvas.Brush.Color := clBlack;
'2':Canvas.Brush.Color := clred;
else
Canvas.Brush.Color := clWhite;
end;
//画图
case s3[i] of
'0':canvas.Rectangle(x-10,y-10,x+10,y+10);
'1':canvas.Ellipse(x-10,y-10,x+10,y+10);
else
canvas.Rectangle(x-10,y-10,x+10,y+10);
end;
inc(i);
end;
end;
canvas.Brush := oldBrush;
canvas.Pen := oldpen;
end;